I want to use the synchronize module to rsync a directory from one place
on the control host to another place on the control host. My playbook
looks like this:
- hosts: all
become: True
gather_facts: False
tasks:
- local_action: copy src=/tmp/foo.txt dest=/tmp/wip/{{inventory_hostname}}.txt
- local_action: synchronize src=/tmp/wip/ dest=/tmp/real
Based on http://docs.ansible.com/ansible/synchronize_module.html, which says
# Synchronization of two paths both on the control machine
local_action: synchronize src=some/relative/path dest=/some/absolute/path
The first task creates a bunch of files in /tmp/wip, with the hostnames
of my hosts in the filename. I expected the second task to use the
synchronize module to copy /tmp/wip to /tmp/real on the control machine,
but instead it copies it to each of the hosts. (run_once: True on the
second task causes it to only copy to one of the hosts, which limits the
damage when testing. :^)
I've tried a couple of things, none of which work. Most surprisingly,
changing the second task to
- synchronize: src=/tmp/wip/ dest=/tmp/real
does exactly the same thing, and some further experimentation suggests
that delegate_to / local_action are only ever affecting the src host, and
never the dest host.
How do you use the synchronize module to copy files from one play to
another on localhost? Is there a way to change the dest host to localhost?
-Josh (jbs@care.com)
(apologies for the automatic corporate disclaimer that follows)
This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.