1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/lib/ansible/plugins/action
Adam DeConinck 2f74f6738d Fix for ansible/ansible-modules-core#1568
When checksums of local and remote files match, and when follow = True,
determine if remote destination is a symlink. If so, de-reference it and
pass the link target to the file module as 'dest'.

This change fixes an edge case in file copy behavior when:

- 'dest' is a symlink to some other file ('realdest')
- follow = True
- the checksums of the source file, 'src', and the symlink target, 'realdest',
  match.

Because the checksums match, the copy module is skipped and the file module
is invoked directly with 'dest' = the symlink, and 'src' = the source of the
copy module, whether that source is present on the target machine or not.

When 'src' doesn't exist on the target machine, this leads to an error that
looks like this because it can't change the target of the symlink:

TASK [copy] ********************************************************************
fatal: [192.168.56.101]: FAILED! => {"changed": false, "checksum": "f572d396fae9206628714fb2ce00f72e94f2258f", "failed": true, "gid": 1000, "group": "ajdecon", "mode": "0777", "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /tmp/issue1568/dest_dir/source", "owner": "ajdecon", "path": "/tmp/issue1568/dest_dir/dest", "size": 8, "src": "source", "state": "link", "uid": 1000}

When the path 'src' *does* exist on the target machine, the file module makes
this the symlink "dest -> src" instead of "dest -> realdest"... even if the
checksum of 'src' on the target machine is different from the checksum of 'src'
on the machine where Ansible is running.
2016-02-23 13:47:51 -07:00
..
__init__.py Merge pull request #14490 from bcoca/stat_instead_of_checksum 2016-02-18 01:45:50 -08:00
add_host.py
assemble.py use stat module instead of checksum code 2016-02-16 08:43:38 -05:00
assert.py
async.py strip BECOME-SUCCESS at lower level 2016-02-09 13:03:18 -05:00
copy.py Fix for ansible/ansible-modules-core#1568 2016-02-23 13:47:51 -07:00
debug.py allow skipping debug depending on verbosity 2016-02-18 06:58:43 -08:00
eos_template.py
fail.py
fetch.py
group_by.py
include_vars.py
ios_template.py
iosxr_template.py adds new action plugin iosxr_template 2016-02-12 17:08:21 -05:00
junos_template.py initial add of new action plugin junos_template 2016-02-11 08:28:35 -05:00
net_template.py
normal.py
nxos_template.py
ops_template.py
package.py
patch.py
pause.py
raw.py strip BECOME-SUCCESS at lower level 2016-02-09 13:03:18 -05:00
script.py strip BECOME-SUCCESS at lower level 2016-02-09 13:03:18 -05:00
set_fact.py
synchronize.py
template.py use stat module instead of checksum code 2016-02-16 08:43:38 -05:00
unarchive.py
win_copy.py
win_template.py