diff --git a/changelogs/fragments/57248-gather_facts-cleanup-tmp.yaml b/changelogs/fragments/57248-gather_facts-cleanup-tmp.yaml new file mode 100644 index 00000000000..f47a495b329 --- /dev/null +++ b/changelogs/fragments/57248-gather_facts-cleanup-tmp.yaml @@ -0,0 +1,2 @@ +bugfixes: + - gather_facts - Clean up tmp files upon completion (https://github.com/ansible/ansible/issues/57248) diff --git a/lib/ansible/plugins/action/gather_facts.py b/lib/ansible/plugins/action/gather_facts.py index e461abe0069..4fa084e1d2d 100644 --- a/lib/ansible/plugins/action/gather_facts.py +++ b/lib/ansible/plugins/action/gather_facts.py @@ -74,6 +74,8 @@ class ActionModule(ActionBase): skipped[fact_module] = res.get('msg') else: result = combine_vars(result, {'ansible_facts': res.get('ansible_facts', {})}) + + self._remove_tmp_path(self._connection._shell.tmpdir) else: # do it async jobs = {}