mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Adding "follow" param for file/copy options
Also modifies the template action plugin to use this new param when executing the file/copy modules for templating so that links are preserved correctly. Fixes #8998
This commit is contained in:
@@ -151,6 +151,7 @@ FILE_COMMON_ARGUMENTS=dict(
|
||||
serole = dict(),
|
||||
selevel = dict(),
|
||||
setype = dict(),
|
||||
follow = dict(type='bool', default=False),
|
||||
# not taken by the file module, but other modules call file so it must ignore them.
|
||||
content = dict(no_log=True),
|
||||
backup = dict(),
|
||||
@@ -295,6 +296,11 @@ class AnsibleModule(object):
|
||||
else:
|
||||
path = os.path.expanduser(path)
|
||||
|
||||
# if the path is a symlink, and we're following links, get
|
||||
# the target of the link instead for testing
|
||||
if params.get('follow', False) and os.path.islink(path):
|
||||
path = os.path.realpath(path)
|
||||
|
||||
mode = params.get('mode', None)
|
||||
owner = params.get('owner', None)
|
||||
group = params.get('group', None)
|
||||
|
||||
Reference in New Issue
Block a user