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
f67949e4
Commit
f67949e4
authored
Jul 07, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Readd logic for ansible_managed to template action plugin
Fixes #11317
parent
bfbb88b4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
lib/ansible/plugins/action/template.py
+32
-0
lib/ansible/vars/__init__.py
+2
-0
No files found.
lib/ansible/plugins/action/template.py
View file @
f67949e4
...
@@ -18,10 +18,14 @@ from __future__ import (absolute_import, division, print_function)
...
@@ -18,10 +18,14 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__
=
type
__metaclass__
=
type
import
base64
import
base64
import
datetime
import
os
import
os
import
time
from
ansible
import
constants
as
C
from
ansible.plugins.action
import
ActionBase
from
ansible.plugins.action
import
ActionBase
from
ansible.utils.hashing
import
checksum_s
from
ansible.utils.hashing
import
checksum_s
from
ansible.utils.unicode
import
to_bytes
class
ActionModule
(
ActionBase
):
class
ActionModule
(
ActionBase
):
...
@@ -97,7 +101,35 @@ class ActionModule(ActionBase):
...
@@ -97,7 +101,35 @@ class ActionModule(ActionBase):
try
:
try
:
with
open
(
source
,
'r'
)
as
f
:
with
open
(
source
,
'r'
)
as
f
:
template_data
=
f
.
read
()
template_data
=
f
.
read
()
try
:
template_uid
=
pwd
.
getpwuid
(
os
.
stat
(
source
)
.
st_uid
)
.
pw_name
except
:
template_uid
=
os
.
stat
(
source
)
.
st_uid
vars
=
task_vars
.
copy
()
vars
[
'template_host'
]
=
os
.
uname
()[
1
]
vars
[
'template_path'
]
=
source
vars
[
'template_mtime'
]
=
datetime
.
datetime
.
fromtimestamp
(
os
.
path
.
getmtime
(
source
))
vars
[
'template_uid'
]
=
template_uid
vars
[
'template_fullpath'
]
=
os
.
path
.
abspath
(
source
)
vars
[
'template_run_date'
]
=
datetime
.
datetime
.
now
()
managed_default
=
C
.
DEFAULT_MANAGED_STR
managed_str
=
managed_default
.
format
(
host
=
vars
[
'template_host'
],
uid
=
vars
[
'template_uid'
],
file
=
to_bytes
(
vars
[
'template_path'
])
)
vars
[
'ansible_managed'
]
=
time
.
strftime
(
managed_str
,
time
.
localtime
(
os
.
path
.
getmtime
(
source
))
)
old_vars
=
self
.
_templar
.
_available_variables
self
.
_templar
.
set_available_variables
(
vars
)
resultant
=
self
.
_templar
.
template
(
template_data
,
preserve_trailing_newlines
=
True
)
resultant
=
self
.
_templar
.
template
(
template_data
,
preserve_trailing_newlines
=
True
)
self
.
_templar
.
set_available_variables
(
old_vars
)
except
Exception
as
e
:
except
Exception
as
e
:
return
dict
(
failed
=
True
,
msg
=
type
(
e
)
.
__name__
+
": "
+
str
(
e
))
return
dict
(
failed
=
True
,
msg
=
type
(
e
)
.
__name__
+
": "
+
str
(
e
))
...
...
lib/ansible/vars/__init__.py
View file @
f67949e4
...
@@ -243,6 +243,8 @@ class VariableManager:
...
@@ -243,6 +243,8 @@ class VariableManager:
# the 'omit' value alows params to be left out if the variable they are based on is undefined
# the 'omit' value alows params to be left out if the variable they are based on is undefined
all_vars
[
'omit'
]
=
self
.
_omit_token
all_vars
[
'omit'
]
=
self
.
_omit_token
# make vars self referential, so people can do things like 'vars[var_name]'
all_vars
[
'vars'
]
=
all_vars
.
copy
()
all_vars
[
'vars'
]
=
all_vars
.
copy
()
#CACHED_VARS[cache_entry] = all_vars
#CACHED_VARS[cache_entry] = all_vars
...
...
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