diff --git a/changelogs/fragments/gather_facts-warnings.yaml b/changelogs/fragments/gather_facts-warnings.yaml new file mode 100644 index 00000000000..ed4ee0155f8 --- /dev/null +++ b/changelogs/fragments/gather_facts-warnings.yaml @@ -0,0 +1,2 @@ +bugfixes: +- fact gathering - Display warnings and deprecation messages that are created during the fact gathering phase diff --git a/lib/ansible/plugins/action/gather_facts.py b/lib/ansible/plugins/action/gather_facts.py index 393df0b0fac..8cc769a7a83 100644 --- a/lib/ansible/plugins/action/gather_facts.py +++ b/lib/ansible/plugins/action/gather_facts.py @@ -45,6 +45,15 @@ class ActionModule(ActionBase): return mod_args + def _combine_task_result(self, result, task_result): + filtered_res = { + 'ansible_facts': task_result.get('ansible_facts', {}), + 'warnings': task_result.get('warnings', []), + 'deprecations': task_result.get('deprecations', []), + } + + return combine_vars(result, filtered_res) + def run(self, tmp=None, task_vars=None): self._supports_check_mode = True @@ -73,7 +82,7 @@ class ActionModule(ActionBase): elif res.get('skipped', False): skipped[fact_module] = res else: - result = combine_vars(result, {'ansible_facts': res.get('ansible_facts', {})}) + result = self._combine_task_result(result, res) self._remove_tmp_path(self._connection._shell.tmpdir) else: @@ -95,7 +104,7 @@ class ActionModule(ActionBase): elif res.get('skipped', False): skipped[module] = res else: - result = combine_vars(result, {'ansible_facts': res.get('ansible_facts', {})}) + result = self._combine_task_result(result, res) del jobs[module] break else: