Hi
I have some troubles to understand how synchronize works… Here is what I have:
Hi
I have some troubles to understand how synchronize works… Here is what I have:
The src host is defined by your inventory host. So if "hosts: localhost", then rsync will run from localhost. The dest path is also on the the inventory host by default, so again if "hosts: localhost" then dest will be <user>@localhost:<path>.
That being said, if you want to rsync to another machine, you can put <user>@<hostname>:<path> for your dest parameter.
Make sure that the user on the src host can connect to the the dest host via ssh key or rsync won't be able to authenticate.
Hi
I want to rsync from another server to localhost.
From documentation:
"# Synchronization of src on delegate host to dest on the current inventory host
synchronize: >
src=some/relative/path dest=/some/absolute/path
delegate_to: delegate.host"
So I have source on delegate host (dbserver) and dest on the current inventory host, which is localhost. But it does not sync back to localhost.
Edgars
otrdiena, 2013. gada 12. novembris 17:09:50 UTC+1, James Tanner rakstīja:
If you are gathering facts, you can do this ...
- hosts: localhost
gather_facts: True
tasks:
- synchronize: src=/tmp/foosrc dest=root@"{{ ansible_default_ipv4.address }}":/tmp/foodest
delegate_to: el6.lab.net
Just tested, and it works if el6.lab.net has an ssh key on localhost.
The whole point of the synchonize module was to avoid all of this mess otherwise you may as well use the command action and craft your own rsync command.
You never have to specify the host in the src or dest. Depending on a combination of variables – connection, invetnory host and delegate host if any – the module does that for you.
Also, if I’m reading Edgars question and James’ solution correctly the src and destination is flipped in both cases.
tasks:
Here files in /opt/dbbackup on the host defined by database_server will be synchronized to /backup/dbbackup on the localhost.