Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synchronize does not follow "delegate_to" setting #7250

Closed
rcp opened this issue May 1, 2014 · 5 comments
Closed

synchronize does not follow "delegate_to" setting #7250

rcp opened this issue May 1, 2014 · 5 comments
Labels
docs This issue/PR relates to or includes documentation.

Comments

@rcp
Copy link

rcp commented May 1, 2014

Issue Type:

Bug Report

Ansible Version:

ansible 1.5, initially. Also tried:
ansible 1.6 (devel 40a7a30) last updated 2014/05/01 11:43:40 (GMT -400)

Environment:

CentOS 6.5 (all hosts)

Summary:

The documentation for the synchronize action leads me to believe (and #ansible IRC chats confirm) that the expected behaviour of the snippet below is that the src of the rsync will be delegate.host:some/relative/path. My experience is that the source is instead some/relative/path on the host from whence the action is issued.

synchronize: >
src=some/relative/path dest=/some/absolute/path
delegate_to: delegate.host

Steps To Reproduce:

Follow bash commands in http://pastebin.com/SA9aHt2J They are also reproduced below.

# bash commands to reproduce ansible problem with 'delegate_to' in 'synchronize'
# edit 'host1' and 'host2', run on a separate host3
#
mkdir -p /tmp/tst/a
ssh host1 mkdir -p /tmp/tst/a/b
cat >/tmp/tst/sync-test.yml <<EOF

---
# Test "delegate_to:" in synchronize action (RUN ON host3!)
- name: ensure soldev in sync with master
  hosts: host2
  remote_user: root
  tasks:
  - name: syncronize /tmp/tst tree (should be from host1)
    synchronize: >
      src=/tmp/tst/ dest=/tmp/tst
      delegate_to: host1
EOF
ansible-playbook -vv /tmp/tst/sync-test.yml 
ssh host2 find /tmp/tst
# see presence of /tmp/tst/sync-test.yml, and absense of /tmp/tst/a/b
Expected Results:
/tmp/tst
/tmp/tst/a
/tmp/tst/a/b
Actual Results:
/tmp/tst
/tmp/tst/sync-test.yml
/tmp/tst/a
@mpdehaan mpdehaan changed the title synchronize does not respect "delegate_to" setting synchronize does not follow "delegate_to" setting May 1, 2014
@mpdehaan
Copy link
Contributor

mpdehaan commented May 1, 2014

Synchronize is a wrapper around producing local_action: shell rsync commands.

It runs between the remote host and the local one, but it can't be used to bridge rsync's between two different hosts.

If you wanted this, I'd just call "shell: rsync" directly.

We can look at making the documentation more clear on this.

@edrozenberg
Copy link
Contributor

I just ran into this same issue - would be great if the docs reflected the fact that it doesn't do a sync between two remote hosts. Also thought it was a bug and was about to file it as such when I found this existing issue report.

Though it certainly would be great if this functionality existed - sync between two remote hosts is a common scenario with many use-cases.

@simonft
Copy link

simonft commented Jun 17, 2014

It runs between the remote host and the local one, but it can't be used to bridge rsync's between two different hosts.

Is this still the case? I'm able to use delegate_to: in a synchronize task and ansible connects to the delegate host, then runs rsync locally on the deletate host to push the directory to the remote host. I had to add the following to allow the delegate to connect to the remote host:

rsync_opts='--rsh "ssh -i /root/.ssh/ansible"' 

Is it a bug that this works?

@flynfish
Copy link

flynfish commented Oct 2, 2014

I also having it working when passing in rsync_opts: '-e "ssh -i /home/openvpnas/.ssh/id_rsa"'

@abadger
Copy link
Contributor

abadger commented Aug 1, 2015

This is working for me in 1.9.2 and we've just merged a patch to make sure that this is working in ansible-2.0 here: #11822

Closing This Ticket

Hi!

We believe recent commits (likely detailed above) should resolve this question or problem for you.

This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular
issue is resolved.

Thank you!

@abadger abadger closed this as completed Aug 1, 2015
@ansibot ansibot added docs This issue/PR relates to or includes documentation. and removed docs_report labels Mar 1, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
docs This issue/PR relates to or includes documentation.
Projects
None yet
Development

No branches or pull requests

7 participants