mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix template module broken when modifying symlinks
Needed to clear unwanted parameters from both args and complex args when calling file module. Fixes #10208
This commit is contained in:
parent
c31831f028
commit
10df1b898c
2 changed files with 42 additions and 2 deletions
|
@ -145,6 +145,7 @@ class ActionModule(object):
|
||||||
# the module to follow links. When doing that, we have to set
|
# the module to follow links. When doing that, we have to set
|
||||||
# original_basename to the template just in case the dest is
|
# original_basename to the template just in case the dest is
|
||||||
# a directory.
|
# a directory.
|
||||||
|
module_args = ''
|
||||||
new_module_args = dict(
|
new_module_args = dict(
|
||||||
src=None,
|
src=None,
|
||||||
original_basename=os.path.basename(source),
|
original_basename=os.path.basename(source),
|
||||||
|
@ -154,6 +155,6 @@ class ActionModule(object):
|
||||||
# rely on the file module to report its changed status
|
# rely on the file module to report its changed status
|
||||||
if self.runner.noop_on_check(inject):
|
if self.runner.noop_on_check(inject):
|
||||||
new_module_args['CHECKMODE'] = True
|
new_module_args['CHECKMODE'] = True
|
||||||
module_args = utils.merge_module_args(module_args, new_module_args)
|
options.update(new_module_args)
|
||||||
return self.runner._execute_module(conn, tmp, 'file', module_args, inject=inject, complex_args=complex_args)
|
return self.runner._execute_module(conn, tmp, 'file', module_args, inject=inject, complex_args=options)
|
||||||
|
|
||||||
|
|
|
@ -96,3 +96,42 @@
|
||||||
- "dir_attrs.stat.uid != 0"
|
- "dir_attrs.stat.uid != 0"
|
||||||
- "dir_attrs.stat.pw_name == 'nobody'"
|
- "dir_attrs.stat.pw_name == 'nobody'"
|
||||||
- "dir_attrs.stat.mode == '0755'"
|
- "dir_attrs.stat.mode == '0755'"
|
||||||
|
|
||||||
|
- name: make a symlink to the templated file
|
||||||
|
file:
|
||||||
|
path: '{{ output_dir }}/foo.symlink'
|
||||||
|
src: '{{ output_dir }}/foo.templated'
|
||||||
|
state: link
|
||||||
|
|
||||||
|
- name: check that templating the symlink results in the file being templated
|
||||||
|
template:
|
||||||
|
src: foo.j2
|
||||||
|
dest: '{{output_dir}}/foo.symlink'
|
||||||
|
mode: 0600
|
||||||
|
follow: True
|
||||||
|
register: template_result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "template_result.changed == True"
|
||||||
|
|
||||||
|
- name: check that the file has the correct attributes
|
||||||
|
stat: path={{output_dir | expanduser}}/template-dir/foo.j2
|
||||||
|
register: file_attrs
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "file_attrs.stat.mode == '0600'"
|
||||||
|
|
||||||
|
- name: check that templating the symlink again makes no changes
|
||||||
|
template:
|
||||||
|
src: foo.j2
|
||||||
|
dest: '{{output_dir}}/foo.symlink'
|
||||||
|
mode: 0600
|
||||||
|
follow: True
|
||||||
|
register: template_result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "template_result.changed == False"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue