How is it possible to move/rename a file/directory using an Ansible module on a remote system? I don't want to use the command/shell tasks and I don't want to copy the file from the local system to the remote system.
相关问题
- Access ansible.cfg variable in task
- Unable to get “exclude” option working with unarch
- Ansible: find file and loop over paths
- Generating tuples variables in ansible templates
- Ansible: setting user on dynamic ec2
相关文章
- Ansible create postgresql user with access to all
- Difference between shell and command in ansible
- How to make Ansible run one certain task only on o
- clone a specific branch from git through ansible p
- Check if a list contains an item in Ansible
- Defining host as variable in Ansible hosts file
- ansible/jinja2 get unique subelements
- Custom credentials in Ansible Tower with Custom Py
The file module doesn't copy files on the remote system. The src parameter is only used by the file module when creating a symlink to a file.
If you want to move/rename a file entirely on a remote system then your best bet is to use the command module to just invoke the appropriate command:
If you want to get fancy then you could first use the stat module to check that foo actually exists:
Bruce wasn't attempting to stat the destination to check whether or not to move the file if it was already there; he was making sure the file to be moved actually existed before attempting the mv.
If your interest, like Tom's, is to only move if the file doesn't already exist, I think we should still integrate Bruce's check into the mix: