Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
feb9ed1d
Commit
feb9ed1d
authored
Oct 20, 2014
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix template module incorrectly handling mode when dest is a directory
Fixes #9350
parent
1e12d302
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
lib/ansible/modules/core
+1
-1
lib/ansible/runner/action_plugins/template.py
+4
-1
test/integration/roles/test_template/tasks/main.yml
+33
-0
No files found.
core
@
fa6d74a9
Subproject commit
5af8d55b0365a5c3278c43b5424bf5f2ddf897b8
Subproject commit
fa6d74a97054d5d5123696d1af94b31ac1a65237
lib/ansible/runner/action_plugins/template.py
View file @
feb9ed1d
...
...
@@ -133,9 +133,12 @@ class ActionModule(object):
# when running the file module based on the template data, we do
# not want the source filename (the name of the template) to be used,
# since this would mess up links, so we clear the src param and tell
# the module to follow links
# the module to follow links. When doing that, we have to set
# original_basename to the template just in case the dest is
# a directory.
new_module_args
=
dict
(
src
=
None
,
original_basename
=
os
.
path
.
basename
(
source
),
follow
=
True
,
)
# be sure to inject the check mode param into the module args and
...
...
test/integration/roles/test_template/tasks/main.yml
View file @
feb9ed1d
...
...
@@ -64,3 +64,36 @@
that
:
-
"
file_result.changed
!=
True"
# VERIFY dest as a directory does not break file attributes
# Note: expanduser is needed to go down the particular codepath that was broken before
-
name
:
setup directory for test
file
:
state=directory dest={{output_dir | expanduser}}/template-dir mode=0755 owner=nobody group=nobody
-
name
:
set file mode when the destination is a directory
template
:
src=foo.j2 dest={{output_dir | expanduser}}/template-dir/ mode=0600 owner=root group=root
-
name
:
set file mode when the destination is a directory
template
:
src=foo.j2 dest={{output_dir | expanduser}}/template-dir/ mode=0600 owner=root group=root
register
:
file_result
-
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.gid
==
0"
-
"
file_attrs.stat.uid
==
0"
-
"
file_attrs.stat.pw_name
==
'root'"
-
"
file_attrs.stat.mode
==
'0600'"
-
name
:
check that the containing directory did not change attributes
stat
:
path={{output_dir | expanduser}}/template-dir/
register
:
dir_attrs
-
assert
:
that
:
-
"
dir_attrs.stat.gid
!=
0"
-
"
dir_attrs.stat.uid
!=
0"
-
"
dir_attrs.stat.pw_name
==
'nobody'"
-
"
dir_attrs.stat.mode
==
'0755'"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment