I'm using adhoc command for example
ansible some_group_of_hosts -m copy -a "src=/some_local_file
dest=/remote_path/" -u someuser --become-user root --ask-pass
--ask-become-pass
After copy in the remote host. I found temp files in the directory ~/.ansible/tmp
How to remove this temp directory on remote host? Using another module like "commmand" ? In the reference of copy ansible module i did not found about remove temp file after copy.
~/.ansible/tmpis a "working" directory for Ansible on remote host.As far as I know, it is not supposed to be removed.
For each task Ansible creates
~/.ansible/tmp/ansible-tmp-12345.1234.12345directory and then cleans up onlyansible-tmp-xxxsubdirectory, and not "root" working directory.You can change this remote path with remote_tmp setting or with environment variable, like:
This will force Ansible to work in
/tmpand not create~/.ansible/tmp. But there's a risk of someone intercepting temporary data inside common/tmpdirectory.