I made a mistake – it’s not “for whatever reason the file cannot be copied” … but it happens (at least) when I can’t open the remote file (permission denied).
[ehymowitz test]$ ls -al cougar
total 8,192
drwx------. 2 ehymowitz ehymowitz 4,096 Oct 3 13:15 .
drwx------. 3 ehymowitz ehymowitz 4,096 Oct 3 13:13 …
[ehymowitz test]$ cat fetch.yaml
gather_facts: no
tasks:
fetch:
src: /etc/sysconfig/iptables
dest: “/home/ehymowitz/ansible/test/cougar/{{inventory_hostname}}.iptables”
flat: yes
[ehymowitz test]$ ansible-playbook fetch.yaml
PLAY [cougar] ******
TASK [fetch] *******
[WARNING]: sftp transfer mechanism failed on [cougar]. Use ANSIBLE_DEBUG=1 to
see detailed information
[WARNING]: scp transfer mechanism failed on [cougar]. Use ANSIBLE_DEBUG=1 to
see detailed information
[WARNING]: piped transfer mechanism failed on [cougar]. Use ANSIBLE_DEBUG=1 to
see detailed information
fatal: [cougar]: FAILED! => {“msg”:
"failed to transfer file to /etc/sysconfig/iptables /home/ehymowitz/ansible/test/cougar/cougar.iptables:\n\ndd:
opening `/etc/sysconfig/iptables’: Permission denied\n"}
to retry, use: --limit @/home/ehymowitz/ansible/test/fetch.retry
PLAY RECAP *******
cougar : ok=0 changed=0 unreachable=0 failed=1
[ehymowitz test]$ ls -al cougar
total 8,192
drwx------. 2 ehymowitz ehymowitz 4,096 Oct 3 13:15 .
drwx------. 3 ehymowitz ehymowitz 4,096 Oct 3 13:13 …
-rw-------. 1 ehymowitz ehymowitz 0 Oct 3 13:15 cougar.iptables
–EbH