ansible: fix temp cleanup regression and add test; closes #397.

issue260
David Wilson 6 years ago
parent e45e5d3e06
commit 1b17aa1d1a

@ -190,7 +190,10 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
"""
# The actual removal is pipelined by Connection.close().
LOG.debug('_remove_tmp_path(%r)', tmp_path)
self._connection._shell.tmpdir = None
# Upstream _remove_tmp_path resets shell.tmpdir here, however
# connection.py uses that as the sole location of the temporary
# directory, if one exists.
# self._connection._shell.tmpdir = None
def _transfer_data(self, remote_path, data):
"""

@ -4,5 +4,6 @@
- import_playbook: make_tmp_path.yml
- import_playbook: remote_expand_user.yml
- import_playbook: remote_file_exists.yml
- import_playbook: remove_tmp_path.yml
- import_playbook: synchronize.yml
- import_playbook: transfer_data.yml

@ -0,0 +1,40 @@
#
# Ensure _remove_tmp_path cleans up the temporary path.
#
#
- name: integration/action/remove_tmp_path.yml
hosts: test-targets
any_errors_fatal: true
tasks:
- meta: end_play
when: not is_mitogen
#
# Use the copy module to cause a temporary directory to be created, and
# return a result with a 'src' attribute pointing into that directory.
#
- copy:
dest: /tmp/remove_tmp_path_test
content: "{{ 123123 | random }}"
register: out
- stat:
path: "{{out.src}}"
register: out2
- assert:
that:
- not out2.stat.exists
- stat:
path: "{{out.src|dirname}}"
register: out2
- assert:
that:
- not out2.stat.exists
- file:
path: /tmp/remove_tmp_path_test
state: absent
Loading…
Cancel
Save