Ed_Wong
(Ed Wong)
August 3, 2020, 7:19am
1
Hi,
I’d like to copy (on a remote system) a file from one directory to another.
What I’m doing is:
– tasks:
– name: copy remote file to local
fetch:
src: “/etc/resolve.conf”
dest": “/tmp/”
owner: root
group: root
mode: ‘0644’
flat: yes
name:
copy:
src: “/tmp/resolve.conf”
dest: “/chroot/etc/”
owner: root
group: root
mode: ‘0644’
While this works, I’m wondering if there’s something a bit less indirect? I’ve looked at
file: but it can only do symlinks(soft ,hard) and create directories and files. From what I see,
it can’t copy a file from dir to another. Or have I misread something?
Thanks
Ed
Ed_Wong
(Ed Wong)
August 3, 2020, 7:44am
2
I somehow missed remote_src. My apologies.
Hi,
fetch module doesn’t owner and group parameters, please revisit the ansible-doc.
EXAMPLES:
name: Store file into /tmp/fetched/host.example.com/tmp/somefile
fetch:
src: /tmp/somefile
dest: /tmp/fetched
name: Specifying a path directly
fetch:
src: /tmp/somefile
dest: /tmp/prefix-{{ inventory_hostname }}
flat: yes
name: Specifying a destination path
fetch:
src: /tmp/uniquefile
dest: /tmp/special/
flat: yes
name: Storing in a path relative to the playbook
fetch:
src: /tmp/uniquefile
dest: special/prefix-{{ inventory_hostname }}
flat: yes
Thanks
Lakshminarayanan. R