Issue 1:
ISSUE TYPE

Bug Report

ANSIBLE VERSION

ansible 2.1.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = ['/usr/share/custom_modules']

CONFIGURATION

pipelining = True

OS / ENVIRONMENT

CentOS Linux release 7.0.1406 (Core)

SUMMARY

When using the synchronize module with become and delegate_to, user that initiated playbook (root) is used when trying to ssh to target host rather than the specified become_user.

STEPS TO REPRODUCE

Create ansible task as shown below

Run playbook

---
- hosts: hosta:hostb
gather_facts: no

tasks:
- name: Copy folder from one server to another
synchronize:
mode: push
src: "/tmp/foo/"
dest: "/tmp/foo"
delegate_to: "hosta"
become: yes
become_user: app_user
become_method: su

EXPECTED RESULTS

/tmp/foo is synchronized from hosta to hostb as user app_user

ACTUAL RESULTS

As shown below, tries to authenticate on target system as root user rather than app_user

Too many authentication failures for root\r\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: unexplained error (code 255) at io.c(600) [sender=3.0.6]\n", "rc": 255}

I tested in 2.0.0.2 and worked ok, in 2.0.2.0 it didn't work, and does not work in latest 2.1.

As a workaround, can add following option to synchronize module

rsync_opts: --rsh "ssh -l app_user -i /app/home/app_user/.ssh/id_rs

This forces the delegated machine to use the key/user already established when performing the rsync.

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

synchronize module

ANSIBLE VERSION

ansible 2.1.0.0

CONFIGURATION

host_key_checking = False

OS / ENVIRONMENT

Fedora 23

SUMMARY

Doing a remote-to-remote push requires using delegate_to. When using synchronize on a host with ansible_user set, and using delegate_to to copy from a second host, Ansible fails to set the remote user for the destination. The remote user is set correctly when delegate_to is removed.

STEPS TO REPRODUCE

The task that triggers the bug:

- synchronize:
src: /home/gemserver/gems/gems
dest: /var/geminabox/gems/gems
delete: yes
delegate_to: "{{ groups['gemserver_master'][0] }}"

EXPECTED RESULTS

When running with -vvv, the "dest" value should report as "user@host:/var/geminabox/gems/gems",

ACTUAL RESULTS

dest is set to just "host:/var/geminabox/gems/gems" (no user@) when delegate_to is present, resulting in being unable to sync.

fatal: [111.111.111.111 -> gemserver-master]: FAILED! => {"changed": false, "cmd": "/usr/bin/rsync --delay-updates -F --compress --dry-run --delete-after --archive --rsh 'ssh -S none -o StrictHostKeyChecking=no' --out-format='<<CHANGED>>%i %n%L' \"/home/gemserver/gems/gems\" \"111.111.111.111:/var/geminabox/gems/gems\"", "failed": true, "invocation": {"module_args": {"_local_rsync_path": "rsync", "_substitute_controller": false, "archive": true, "checksum": false, "compress": true, "copy_links": null, "delete": true, "dest": "111.111.111.111:/var/geminabox/gems/gems", "dest_port": 22, "dirs": false, "existing_only": false, "group": null, "links": null, "mode": "push", "owner": null, "partial": false, "perms": null, "private_key": null, "recursive": null, "rsync_opts": null, "rsync_path": null, "rsync_timeout": 0, "set_remote_user": true, "src": "/home/gemserver/gems/gems", "ssh_args": null, "times": null, "verify_host": false}}, "msg": "Permission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]\n", "rc": 255}

(IP address replaced with 111.111.111.111)