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
9ed59da2
Commit
9ed59da2
authored
Oct 03, 2012
by
Jan-Piet Mens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow user-specified $ansible_managed string with named parameters
parent
53d24ef0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
3 deletions
+18
-3
examples/ansible.cfg
+8
-0
lib/ansible/constants.py
+1
-0
lib/ansible/utils.py
+9
-3
No files found.
examples/ansible.cfg
View file @
9ed59da2
...
...
@@ -66,6 +66,14 @@ remote_port=22
#private_key_file=/path/to/file
# format of string $ansible_managed available within Jinja2 templates, replacing
# {file}, {host} and {uid} with template filename, host and owner respectively.
# The resulting string is passed through strftime(3) so it may contain any
# time-formatting specifiers.
#
# Example: ansible_managed = DONT TOUCH {file}: call {uid} at {host} for changes
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
[paramiko_connection]
# nothing to configure yet
...
...
lib/ansible/constants.py
View file @
9ed59da2
...
...
@@ -78,6 +78,7 @@ DEFAULT_PRIVATE_KEY_FILE = shell_expand_path(get_config(p, DEFAULTS, 'private_k
DEFAULT_SUDO_USER
=
get_config
(
p
,
DEFAULTS
,
'sudo_user'
,
'ANSIBLE_SUDO_USER'
,
'root'
)
DEFAULT_REMOTE_PORT
=
int
(
get_config
(
p
,
DEFAULTS
,
'remote_port'
,
'ANSIBLE_REMOTE_PORT'
,
22
))
DEFAULT_TRANSPORT
=
get_config
(
p
,
DEFAULTS
,
'transport'
,
'ANSIBLE_TRANSPORT'
,
'paramiko'
)
DEFAULT_MANAGED_STR
=
get_config
(
p
,
DEFAULTS
,
'ansible_managed'
,
None
,
'Ansible managed: {file} modified on
%
Y-
%
m-
%
d
%
H:
%
M:
%
S by {uid} on {host}'
)
# non-configurable things
DEFAULT_REMOTE_PASS
=
None
...
...
lib/ansible/utils.py
View file @
9ed59da2
...
...
@@ -408,9 +408,15 @@ def template_from_file(basedir, path, vars):
vars
[
'template_path'
]
=
realpath
vars
[
'template_mtime'
]
=
datetime
.
datetime
.
fromtimestamp
(
os
.
path
.
getmtime
(
realpath
))
vars
[
'template_uid'
]
=
template_uid
vars
[
'ansible_managed'
]
=
"
%
s on
%
s, modified
%
s by
%
s"
%
(
vars
[
'template_path'
],
vars
[
'template_host'
],
vars
[
'template_mtime'
],
vars
[
'template_uid'
]
)
managed_default
=
C
.
DEFAULT_MANAGED_STR
managed_str
=
managed_default
.
format
(
host
=
vars
[
'template_host'
],
uid
=
vars
[
'template_uid'
],
file
=
vars
[
'template_path'
]
)
vars
[
'ansible_managed'
]
=
time
.
strftime
(
managed_str
,
time
.
localtime
(
os
.
path
.
getmtime
(
realpath
)))
res
=
t
.
render
(
vars
)
if
data
.
endswith
(
'
\n
'
)
and
not
res
.
endswith
(
'
\n
'
):
...
...
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