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 3ab5934e04a..0747a391f9c 100644 --- a/lib/ansible/plugins/action/gather_facts.py +++ b/lib/ansible/plugins/action/gather_facts.py @@ -70,6 +70,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 = {}