Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

synchronize

ANSIBLE VERSION

2.3.0.0

CONFIGURATION

ansible.cfg

[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=600s
control_path = %(directory)s/%%h-%%r
pipelining = True

OS / ENVIRONMENT

Linux 4.10.10-1-MANJARO

SUMMARY

Rsync synchronization does not work on 2.3.0.0, works on 2.2.2.0

STEPS TO REPRODUCE

- name: Rsync upload to server
synchronize: src={{ config_local_path }} dest={{ rails_release_path }} rsync_opts=--exclude-from='{{ config_local_path }}.gitignore' owner=no group=no
become: yes
become_user: "{{ user }}"

EXPECTED RESULTS

On version 2.2.2.0 works as expected, executing

/usr/bin/rsync --delay-updates -F --compress --archive --no-owner --no-group --rsh 'ssh -S none -o StrictHostKeyChecking=no' --rsync-path=\"sudo rsync\" --exclude-from='/home/kostafun/Projects/domain.com/.gitignore' --out-format='<<CHANGED>>%i %n%L' \"/home/kostafun/Projects/domain.com/\" \"root@2.2.2.2:/home/bk/domain/releases/20170423080009\"

ACTUAL RESULTS

On 2.3.0.0 executing

/usr/bin/rsync --delay-updates -F --compress --archive --no-owner --no-group --rsh=/usr/bin/ssh -S none -o StrictHostKeyChecking=no --rsync-path=sudo rsync --exclude-from='/home/kostafun/Projects/domain.com/.gitignore' --out-format=<<CHANGED>>%i %n%L /home/kostafun/Projects/domain.com/ root@2.2.2.2:/home/bk/domain/releases/20170423070910

with the following results

rsync: failed to open exclude file '/home/kostafun/Projects/domain.com/.gitignore': No such file or directory (2)\nrsync error: error in file IO (code 11) at exclude.c(1178) [client=3.1.2]\n

Note no quotes --rsync-path=sudo rsync --out-format=<>%i %n%L

Commit #23157 ?

Complete -vvv output:

Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/synchronize.py
<2.2.2.2> ESTABLISH LOCAL CONNECTION FOR USER: kostafun
<2.2.2.2> EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'
fatal: [2.2.2.2]: FAILED! => {
"changed": false,
"cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --no-owner --no-group --rsh=/usr/bin/ssh -S none -o StrictHostKeyChecking=no --rsync-path=sudo rsync --exclude-from='/home/kostafun/Projects/domain.com/.gitignore' --out-format=<<CHANGED>>%i %n%L /home/kostafun/Projects/domain.com/ root@2.2.2.2:/home/bk/domain/releases/20170423070910",
"failed": true,
"invocation": {
"module_args": {
"_local_rsync_path": "rsync",
"_substitute_controller": false,
"archive": true,
"checksum": false,
"compress": true,
"copy_links": false,
"delete": false,
"dest": "root@2.2.2.2:/home/bk/domain/releases/20170423070910",
"dest_port": null,
"dirs": false,
"existing_only": false,
"group": false,
"links": null,
"mode": "push",
"owner": false,
"partial": false,
"perms": null,
"private_key": null,
"recursive": null,
"rsync_opts": [
"--exclude-from='/home/kostafun/Projects/domain.com/.gitignore'"
],
"rsync_path": "sudo rsync",
"rsync_timeout": 0,
"set_remote_user": true,
"src": "/home/kostafun/Projects/domain.com/",
"ssh_args": null,
"times": null,
"verify_host": false
}
},
"msg": "rsync: failed to open exclude file '/home/kostafun/Projects/domain.com/.gitignore': No such file or directory (2)\nrsync error: error in file IO (code 11) at exclude.c(1178) [client=3.1.2]\n",
"rc": 11
}

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

synchronize

ANSIBLE VERSION

ansible 2.3.0.0
config file = /tmp/ansible-test/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.13 (default, Jan 12 2017, 17:59:37) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

synchronize doesn't handle rsync_opts correctly.

In my case, the --exclude option was ignored, fscking up my webserver config.

ansible 2.2.2.0 works fine, though.

STEPS TO REPRODUCE

https://gist.github.com/philfry/9b7d4ac4ce2dc511accc3ba8e150ef40

EXPECTED RESULTS

*.conf get synchronized, *.module are left untouched.

/tmp/foo-dest/dontdeleteme2.module
/tmp/foo-dest/dontdeleteme1.module
/tmp/foo-dest/someconfig.conf
/tmp/foo-dest/overwriteme.conf
/tmp/foo-dest/anotherconf.conf

/tmp/foo-src/anotherconf.conf
/tmp/foo-src/overwriteme.conf

ACTUAL RESULTS

*.conf get synchronized, *.module get deleted.

/tmp/foo-dest/overwriteme.conf
/tmp/foo-dest/anotherconf.conf

/tmp/foo-src/anotherconf.conf
/tmp/foo-src/overwriteme.conf

https://gist.github.com/philfry/d5e3c38c94f3ad631196aff37aea22de