I also tried using a copy with a delegate_to and that's not working
either (the src couldn't be found). Here's a playbook and the output
from the run:
]$ cat test3.yml
---
- hosts: all
remote_user: sg
sudo: true
tasks:
- name: create remote file
file: path=/tmp/XYZ123 state=touch
delegate_to: '{{ delegate_host }}'
- name: testing delegate copy
copy: src=/tmp/XYZ123 dest=/tmp/ABC456
delegate_to: '{{ delegate_host }}'
]$ ansible-playbook test3.yml -l app1 -e 'delegate_host=10.0.1.86' -vvv
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
<10.0.1.89> ESTABLISH CONNECTION FOR USER: sg on PORT 22 TO 10.0.1.89
<10.0.1.89> REMOTE_MODULE setup
<10.0.1.89> EXEC /bin/sh -c 'mkdir -p
$HOME/.ansible/tmp/ansible-tmp-1400696767.07-233153692139034 && chmod
a+rx $HOME/.ansible/tmp/ansible-tmp-1400696767.07-233153692139034 &&
echo $HOME/.ansible/tmp/ansible-tmp-1400696767.07-233153692139034'
<10.0.1.89> PUT /tmp/tmp6bGYDw TO
/home/sg/.ansible/tmp/ansible-tmp-1400696767.07-233153692139034/setup
<10.0.1.89> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via
ansible, key=bbgqvwdsjhbplqqmobpwlqwybvofjfuw] password: " -u root
/bin/sh -c '"'"'echo SUDO-SUCCESS-bbgqvwdsjhbplqqmobpwlqwybvofjfuw;
LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python
/home/sg/.ansible/tmp/ansible-tmp-1400696767.07-233153692139034/setup;
rm -rf /home/sg/.ansible/tmp/ansible-tmp-1400696767.07-233153692139034/
>/dev/null 2>&1'"'"''
ok: [app1]
TASK: [create remote file] ****************************************************
<10.0.1.86> ESTABLISH CONNECTION FOR USER: sg on PORT 22 TO 10.0.1.86
<10.0.1.86> REMOTE_MODULE file path=/tmp/XYZ123 state=touch
<10.0.1.86> EXEC /bin/sh -c 'mkdir -p
$HOME/.ansible/tmp/ansible-tmp-1400696768.62-116058327340724 && chmod
a+rx $HOME/.ansible/tmp/ansible-tmp-1400696768.62-116058327340724 &&
echo $HOME/.ansible/tmp/ansible-tmp-1400696768.62-116058327340724'
<10.0.1.86> PUT /tmp/tmpvpuHFg TO
/home/sg/.ansible/tmp/ansible-tmp-1400696768.62-116058327340724/file
<10.0.1.86> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via
ansible, key=fmymfhqecsgxkmngwtllopvyzgarrtjn] password: " -u root
/bin/sh -c '"'"'echo SUDO-SUCCESS-fmymfhqecsgxkmngwtllopvyzgarrtjn;
LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python
/home/sg/.ansible/tmp/ansible-tmp-1400696768.62-116058327340724/file;
rm -rf /home/sg/.ansible/tmp/ansible-tmp-1400696768.62-116058327340724/
>/dev/null 2>&1'"'"''
changed: [app1] => {"changed": true, "dest": "/tmp/XYZ123", "gid": 0,
"group": "root", "mode": "0644", "owner": "root", "size": 0, "state":
"file", "uid": 0}
TASK: [testing delegate copy] *************************************************
<10.0.1.86> ESTABLISH CONNECTION FOR USER: sg on PORT 22 TO 10.0.1.86
failed: [app1] => {"failed": true}
msg: could not find src=/tmp/XYZ123
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/sg/test3.retry
app1 : ok=2 changed=1 unreachable=0 failed=1
I should also note that running this will hang too at the end, but a
single <enter> brings it back to the prompt. Maybe that's connected to
the ssh-inside-ssh problem I'm having as well with STDIN waiting on a
carriage-return somewhere but STDIN not being tied to my terminal...
On Wed, May 21, 2014 at 2:16 PM, Michael Peters
<[email protected]> wrote:
> I was trying to do this via ssh or scp but that's not working (see
> https://groups.google.com/forum/#!msg/ansible-project/WPVGypBbwlU/mYN5B4wp4ogJ).
> I need to transfer a file on one server (who's ip is determined via a
> variable and isn't necessarily being managed by ansible) to another
> ansible managed server.
>
> I tried using something like this:
>
> - name: Copy file
> command: 'scp /tmp/file.tar.gz {{ ansible_all_ipv4_addresses[0]
> }}:/tmp/file.tar.gz'
> delegate_to: '{{ other_host }}'
>
> Like my problems in the above mentioned discussion this just hangs
> when run via ansible, but runs fine when executed as the same user on
> other_host.
>
> I was just wondering if there is a better way. I could break it up
> into 2 steps with a fetch and copy but my control server is pretty
> small and these files are going to be pretty large. Surely other
> people have automated the movement of large files in their systems
> with ansible, right?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAJQqANeCE66ktNvExO%3D9vL_xewRPVFQdJK1NBUJFyJbPXxF8vA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.