ansible fetch fails but creates zero-length file

33 views
Skip to first unread message

eric.b....@nasa.gov

unread,
Oct 2, 2018, 1:45:38 PM10/2/18
to Ansible Project
When I use the fetch module (with or without using become, which is contra-indicated but I have no choice), and for whatever reason the file cannot be copied, the local machine still creates a zero-length file.  Is there a way to disable this behavior?

Thanks.

--EbH

Brad Van Orden

unread,
Oct 3, 2018, 8:44:55 AM10/3/18
to Ansible Project
Eric,

Can you provide your task?  Any error messages?

Hymowitz, Eric B. (GSFC-444.0)[KBRwyle]

unread,
Oct 3, 2018, 9:20:46 AM10/3/18
to ansible...@googlegroups.com

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.

Brad Van Orden

unread,
Oct 3, 2018, 10:20:43 AM10/3/18
to Ansible Project
I think not using become is what is killing you.  iptables is definitely only readable by root.  Try turning "become" back on.


On Tuesday, October 2, 2018 at 1:45:38 PM UTC-4, eric.b....@nasa.gov wrote:

Hymowitz, Eric B. (GSFC-444.0)[KBRwyle]

unread,
Oct 3, 2018, 10:33:38 AM10/3/18
to ansible...@googlegroups.com

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.

Brad Van Orden

unread,
Oct 3, 2018, 10:37:34 AM10/3/18
to Ansible Project
Not necessarily.  Depends on the order of execution within the module.  It might "touch" the destination before attempting the copy and may not delete it if the copy fails.  Not sure.  You'd have to look at the source code of the fetch module.  :)


On Tuesday, October 2, 2018 at 1:45:38 PM UTC-4, eric.b....@nasa.gov wrote:
Reply all
Reply to author
Forward
0 new messages