1.5 synchronize module does not copy from Ansible controller to inventory target

I’m trying to copy a bunch of files, recurisvely, from my Ansible control machine to the inventory target. The ‘synchronize’ module (in 1.5) sounds like it does just what I need:

# Synchronization of src on the control machine to dest on the remote hosts
synchronize: src=some/relative/path dest=/some/absolute/path

When I use it, however, it tries to copy from the target machine to the target machine.
- synchronize:  src=/Users/chris/Projects/smd/ dest=/tmp/
msg: rsync: change_dir "/Users/chris/Projects/smd" failed: No such file or directory (2)

/Users/chris/Projects/smd does exist on my controller, but not my target; it appears it's treating both src and dest on the target.
If I try and make this a local_action, it tries to copy from and *to* my ansible controller machine
- local_action: synchronize src=/Users/chris/.MacOSX dest=/tmp

Does copy my local machine's homedir config info to my local machine's /tmp/ dir
I've read a bunch of the threads on this but it's not clear how to invoke this common operation, abut more importantly, the doc example that state "src on control machine to dest on remote hosts" is not what this module is actually doing.
I've thrown some 'pdb' into the synchronize.py module and see that (without local_action) it does create an rsync command, copy a file with that command to the remote, then run it there, so it makes sense that it would be doing src and dest on the remote -- contrary to the doc example.

Any suggestions?
Thanks

Please show us the ansible-playbook -vvvv output for the task.

Here’s the play:

  • name: Drupal | Add Libraries & Modules (synchronize)

synchronize: src=…/roles/drupal-install/files/{{ item }} dest={{ drupal_path }}/sites/all/
sudo: no
with_items:

  • libraries
  • modules
    tags: sync

And the run:

(drupal-ansible)bash-3.2$ ansible-playbook -t sync -i hosts/vagrant playbooks/drupal-boostrap.yml -vvvv

PLAY [webservers] *************************************************************

GATHERING FACTS ***************************************************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: ubuntu
<127.0.0.1> REMOTE_MODULE setup
<127.0.0.1> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=2222’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, ‘127.0.0.1’, “/bin/sh -c ‘mkdir -p /tmp/ansible-tmp-1394216215.84-11086530114397 && chmod a+rx /tmp/ansible-tmp-1394216215.84-11086530114397 && echo /tmp/ansible-tmp-1394216215.84-11086530114397’”]
<127.0.0.1> PUT /var/folders/03/j6n21gy53ks5dk80cyh9c5800000gn/T/tmp4cvLiN TO /tmp/ansible-tmp-1394216215.84-11086530114397/setup
<127.0.0.1> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=2222’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, ‘127.0.0.1’, ‘/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=zvkuutgiqcazqeyectujmpnblbhrfkni] password: " -u root /bin/sh -c '”'“'echo SUDO-SUCCESS-zvkuutgiqcazqeyectujmpnblbhrfkni; /usr/bin/python /tmp/ansible-tmp-1394216215.84-11086530114397/setup; rm -rf /tmp/ansible-tmp-1394216215.84-11086530114397/ >/dev/null 2>&1'”'"''’]
ok: [127.0.0.1]

TASK: [drupal-install | Drupal | Add Libraries & Modules (synchronize)] *******
<127.0.0.1> ESTABLISH CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=2222’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, ‘127.0.0.1’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1394216217.23-26780158979732 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1394216217.23-26780158979732 && echo $HOME/.ansible/tmp/ansible-tmp-1394216217.23-26780158979732’”]
<127.0.0.1> PUT /var/folders/03/j6n21gy53ks5dk80cyh9c5800000gn/T/tmp66LBCq TO /home/ubuntu/.ansible/tmp/ansible-tmp-1394216217.23-26780158979732/synchronize
<127.0.0.1> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=2222’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, ‘127.0.0.1’, “/bin/sh -c ‘/usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1394216217.23-26780158979732/synchronize; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1394216217.23-26780158979732/ >/dev/null 2>&1’”]
failed: [127.0.0.1] => (item=libraries) => {“cmd”: “rsync --delay-updates -FF --compress --timeout=10 --archive --rsh ‘ssh -o StrictHostKeyChecking=no -o Port=2222’ --out-format=‘<>%i %n%L’ …/roles/drupal-install/files/libraries /home/ubuntu/www/drupal//sites/all/”, “failed”: true, “item”: “libraries”, “rc”: 23}
msg: rsync: change_dir “/home/ubuntu//…/roles/drupal-install/files” failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]

<127.0.0.1> ESTABLISH CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=2222’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, ‘127.0.0.1’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1394216217.47-32135159071547 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1394216217.47-32135159071547 && echo $HOME/.ansible/tmp/ansible-tmp-1394216217.47-32135159071547’”]
<127.0.0.1> PUT /var/folders/03/j6n21gy53ks5dk80cyh9c5800000gn/T/tmpuAQh52 TO /home/ubuntu/.ansible/tmp/ansible-tmp-1394216217.47-32135159071547/synchronize
<127.0.0.1> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=2222’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, ‘127.0.0.1’, “/bin/sh -c ‘/usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1394216217.47-32135159071547/synchronize; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1394216217.47-32135159071547/ >/dev/null 2>&1’”]
failed: [127.0.0.1] => (item=modules) => {“cmd”: “rsync --delay-updates -FF --compress --timeout=10 --archive --rsh ‘ssh -o StrictHostKeyChecking=no -o Port=2222’ --out-format=‘<>%i %n%L’ …/roles/drupal-install/files/modules /home/ubuntu/www/drupal//sites/all/”, “failed”: true, “item”: “modules”, “rc”: 23}
msg: rsync: change_dir “/home/ubuntu//…/roles/drupal-install/files” failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]

FATAL: all hosts have already failed – aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/Users/chris/drupal-boostrap.retry

127.0.0.1 : ok=1 changed=0 unreachable=0 failed=1

Looks like you are using vagrant with the virtualbox provisioner. Can we see the inventory file just to confirm? Should exist next to your vagrant file if you were using vagrant provision.

I haven’t yet tried the Ansible provisioner in Vagrant (too ignorant), was just trying to get a VirtualBox up and running instead of using AWS instances I had been running against. So I hacked out the least Puppet i needed to get an account that Ansible could use. In my Vagrantfile:

config.vm.provision :puppet do |puppet|
puppet.module_path = “puppet/modules”
puppet.manifests_path = “puppet/manifests”
puppet.manifest_file = “create-ubuntu-user.pp”
end

It gives me a box I can SSH to on localhost with port 2222.

Then in the Ansible inventory file, hosts/vagrant I have:

[webservers]
127.0.0.1

[webservers:vars]
ansible_ssh_port=2222

Oh… “localhost”… duh, hmmm. I wonder if it’s confused because the Ansible controller is localhost and so is the Vagrant box target, albeit with a different port?

Thanks.

Would you mind trying it this way? … [webservers] default ansible_ssh_host=127.0.0.1 [webservers:vars] ansible_ssh_port=2222 I suspect delegation to a host named ‘127.0.0.1’ might be problematic for the synchronize action plugin.

OK, that worked fine. I don’t understand why, however. :frowning:

Thanks for your help!