mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07: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:
parent
79a2e586fe
commit
b376e208c7
7 changed files with 96 additions and 13 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue