diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2019-07-11 14:18:32 -0400 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2019-07-16 19:50:37 -0700 |
commit | e6c93bea0d507c26758963a2352f55d5414edd3c (patch) | |
tree | 6901ac03aefae642f6593da3b645f2b9e0b3735b | |
parent | 0f292cd886d23d39815f761c873a2978718f04d4 (diff) | |
download | ansible-e6c93bea0d507c26758963a2352f55d5414edd3c.tar.gz |
Fix gather_facts error/skipped reporting (#58927)
now give back full output from each module executed
fixes #57204
(cherry picked from commit adea964c3e58a30118a6b4a5a45a835b4f3b68a8)
-rw-r--r-- | changelogs/fragments/fix_gathering_reporting.yml | 2 | ||||
-rw-r--r-- | lib/ansible/plugins/action/gather_facts.py | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/changelogs/fragments/fix_gathering_reporting.yml b/changelogs/fragments/fix_gathering_reporting.yml new file mode 100644 index 0000000000..da98bb6848 --- /dev/null +++ b/changelogs/fragments/fix_gathering_reporting.yml @@ -0,0 +1,2 @@ +bugfixes: + - gather_facts now correctly passes back the full output of modules on error and skipped, fixes #57204 diff --git a/lib/ansible/plugins/action/gather_facts.py b/lib/ansible/plugins/action/gather_facts.py index 872c497b6c..f08cd0a8ab 100644 --- a/lib/ansible/plugins/action/gather_facts.py +++ b/lib/ansible/plugins/action/gather_facts.py @@ -65,9 +65,9 @@ class ActionModule(ActionBase): mod_args = self._get_module_args(fact_module, task_vars) res = self._execute_module(module_name=fact_module, module_args=mod_args, task_vars=task_vars, wrap_async=False) if res.get('failed', False): - failed[fact_module] = res.get('msg') + failed[fact_module] = res elif res.get('skipped', False): - skipped[fact_module] = res.get('msg') + skipped[fact_module] = res else: result = combine_vars(result, {'ansible_facts': res.get('ansible_facts', {})}) @@ -87,9 +87,9 @@ class ActionModule(ActionBase): res = self._execute_module(module_name='async_status', module_args=poll_args, task_vars=task_vars, wrap_async=False) if res.get('finished', 0) == 1: if res.get('failed', False): - failed[module] = res.get('msg') + failed[module] = res elif res.get('skipped', False): - skipped[module] = res.get('msg') + skipped[module] = res else: result = combine_vars(result, {'ansible_facts': res.get('ansible_facts', {})}) del jobs[module] @@ -101,16 +101,14 @@ class ActionModule(ActionBase): if skipped: result['msg'] = "The following modules were skipped: %s\n" % (', '.join(skipped.keys())) - for skip in skipped: - result['msg'] += ' %s: %s\n' % (skip, skipped[skip]) + result['skipped_modules'] = skipped if len(skipped) == len(modules): result['skipped'] = True if failed: result['failed'] = True result['msg'] = "The following modules failed to execute: %s\n" % (', '.join(failed.keys())) - for fail in failed: - result['msg'] += ' %s: %s\n' % (fail, failed[fail]) + result['failed_modules'] = failed # tell executor facts were gathered result['ansible_facts']['_ansible_facts_gathered'] = True |