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
- hosts: cougar
gather_facts: no
tasks:
- name: fetch
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
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/ansible-project/17x7STEFyDg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
ansible-proje...@googlegroups.com.
To post to this group, send email to
ansible...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/404be531-7cc1-4fd4-b383-0964a65d0947%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
My problem isn’t “the file didn’t copy”. I know why the file didn’t copy.
The question is, why did a zero-length destination file appear when the file didn’t copy? If the file didn’t copy, then my destination should not exist.
--EbH
From: ansible...@googlegroups.com <ansible...@googlegroups.com>
On Behalf Of Brad Van Orden
Sent: Wednesday, 3 October, 2018 10:21
To: Ansible Project <ansible...@googlegroups.com>
Subject: [ansible-project] Re: ansible fetch fails but creates zero-length file
I think not using become is what is killing you. iptables is definitely only readable by root. Try turning "become" back on.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/ansible-project/17x7STEFyDg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
ansible-proje...@googlegroups.com.
To post to this group, send email to
ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/df52bd29-1f88-427e-b502-752398de1b58%40googlegroups.com.