mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
remove action plugin only fields from 'file' calls (#31047)
* remove action plugin only fields from 'file' calls fixes #30556 * Add a test for #30556
This commit is contained in:
parent
92f777e815
commit
ac9278ff0f
2 changed files with 13 additions and 9 deletions
|
@ -186,6 +186,10 @@ def _walk_dirs(topdir, base_path=None, local_follow=False, trailing_slash_detect
|
|||
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
def _create_remote_file_args(self, module_args):
|
||||
# remove action plugin only keys
|
||||
return dict((k, v) for k, v in module_args.items() if k not in ('content', 'decrypt'))
|
||||
|
||||
def _copy_file(self, source_full, source_rel, content, content_tempfile,
|
||||
dest, task_vars, tmp, delete_remote_tmp):
|
||||
decrypt = boolean(self._task.args.get('decrypt', True), strict=False)
|
||||
|
@ -286,7 +290,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
# src and dest here come after original and override them
|
||||
# we pass dest only to make sure it includes trailing slash in case of recursive copy
|
||||
new_module_args = self._task.args.copy()
|
||||
new_module_args = self._create_remote_file_args(self._task.args)
|
||||
new_module_args.update(
|
||||
dict(
|
||||
src=tmp_src,
|
||||
|
@ -297,11 +301,6 @@ class ActionModule(ActionBase):
|
|||
if lmode:
|
||||
new_module_args['mode'] = lmode
|
||||
|
||||
# remove action plugin only keys
|
||||
for key in ('content', 'decrypt'):
|
||||
if key in new_module_args:
|
||||
del new_module_args[key]
|
||||
|
||||
module_return = self._execute_module(module_name='copy',
|
||||
module_args=new_module_args, task_vars=task_vars,
|
||||
tmp=tmp, delete_remote_tmp=delete_remote_tmp)
|
||||
|
@ -326,7 +325,7 @@ class ActionModule(ActionBase):
|
|||
dest = dest_status_nofollow['lnk_source']
|
||||
|
||||
# Build temporary module_args.
|
||||
new_module_args = self._task.args.copy()
|
||||
new_module_args = self._create_remote_file_args(self._task.args)
|
||||
new_module_args.update(
|
||||
dict(
|
||||
src=source_rel,
|
||||
|
@ -335,6 +334,7 @@ class ActionModule(ActionBase):
|
|||
state='file',
|
||||
)
|
||||
)
|
||||
|
||||
if lmode:
|
||||
new_module_args['mode'] = lmode
|
||||
|
||||
|
@ -513,8 +513,7 @@ class ActionModule(ActionBase):
|
|||
for source_full, source_rel in source_files['files']:
|
||||
# copy files over. This happens first as directories that have
|
||||
# a file do not need to be created later
|
||||
module_return = self._copy_file(source_full, source_rel, content, content_tempfile,
|
||||
dest, task_vars, tmp, delete_remote_tmp)
|
||||
module_return = self._copy_file(source_full, source_rel, content, content_tempfile, dest, task_vars, tmp, delete_remote_tmp)
|
||||
if module_return is None:
|
||||
continue
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
copy:
|
||||
src: foo.txt
|
||||
dest: "{{ remote_file }}"
|
||||
decrypt: no
|
||||
register: copy_result2
|
||||
|
||||
- name: Assert that the file was not changed
|
||||
|
@ -113,6 +114,7 @@
|
|||
copy:
|
||||
content: "modified"
|
||||
dest: "{{ remote_file }}"
|
||||
decrypt: no
|
||||
register: copy_result3
|
||||
|
||||
- name: Check the stat results of the file
|
||||
|
@ -137,6 +139,7 @@
|
|||
content: "modified"
|
||||
dest: "{{ remote_file }}"
|
||||
mode: 0700
|
||||
decrypt: no
|
||||
register: copy_result4
|
||||
|
||||
- name: Check the stat results of the file
|
||||
|
@ -167,6 +170,7 @@
|
|||
content: 'modified'
|
||||
dest: '{{ remote_file }}'
|
||||
mode: 0700
|
||||
decrypt: no
|
||||
register: copy_results
|
||||
|
||||
- name: Check the stat results of the file
|
||||
|
@ -191,6 +195,7 @@
|
|||
content: 'modified'
|
||||
dest: '{{ remote_file }}'
|
||||
mode: 0404
|
||||
decrypt: no
|
||||
register: copy_results
|
||||
|
||||
- name: Check the stat results of the file
|
||||
|
|
Loading…
Reference in a new issue