如何使用远程系统上的 Ansible 模块移动/重命名文件/目录?我不想使用命令/shell 任务,也不想将文件从本地系统复制到远程系统。
从2.0版本开始, in 复制模块 https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html您可以使用remote_src
范围。
If True
它将转到远程/目标计算机以获取 src。
- name: Copy files from foo to bar
copy: remote_src=True src=/path/to/foo dest=/path/to/bar
如果你想移动文件,你需要使用文件模块删除旧文件
- name: Remove old files foo
file: path=/path/to/foo state=absent
从2.8版本开始 复制模块 https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html remote_src
支持递归复制。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)