mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -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
|
@ -125,6 +125,7 @@ def main():
|
|||
force = params['force']
|
||||
diff_peek = params['diff_peek']
|
||||
src = params['src']
|
||||
follow = params['follow']
|
||||
|
||||
# modify source as we later reload and pass, specially relevant when used by other modules.
|
||||
params['path'] = path = os.path.expanduser(params['path'])
|
||||
|
@ -177,15 +178,20 @@ def main():
|
|||
params['path'] = path = os.path.join(path, basename)
|
||||
else:
|
||||
if state in ['link','hard']:
|
||||
module.fail_json(msg='src and dest are required for creating links')
|
||||
|
||||
file_args = module.load_file_common_arguments(params)
|
||||
changed = False
|
||||
if follow:
|
||||
# use the current target of the link as the source
|
||||
src = os.readlink(path)
|
||||
else:
|
||||
module.fail_json(msg='src and dest are required for creating links')
|
||||
|
||||
# make sure the target path is a directory when we're doing a recursive operation
|
||||
recurse = params['recurse']
|
||||
if recurse and state != 'directory':
|
||||
module.fail_json(path=path, msg="recurse option requires state to be 'directory'")
|
||||
|
||||
file_args = module.load_file_common_arguments(params)
|
||||
changed = False
|
||||
|
||||
if state == 'absent':
|
||||
if state != prev_state:
|
||||
if not module.check_mode:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue