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
0935506d
Commit
0935506d
authored
Mar 05, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Templating as non-root should not require passing in the metadata= parameter.
parent
4ee4ddcd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
lib/ansible/playbook.py
+0
-2
lib/ansible/runner.py
+20
-1
No files found.
lib/ansible/playbook.py
View file @
0935506d
...
@@ -306,8 +306,6 @@ class PlayBook(object):
...
@@ -306,8 +306,6 @@ class PlayBook(object):
push_var_str
=
''
push_var_str
=
''
for
(
k
,
v
)
in
vars
.
items
():
for
(
k
,
v
)
in
vars
.
items
():
push_var_str
+=
"
%
s=
%
s "
%
(
k
,
v
)
push_var_str
+=
"
%
s=
%
s "
%
(
k
,
v
)
if
user
!=
'root'
:
push_var_str
=
"
%
s metadata=~/.ansible_setup"
%
(
push_var_str
)
# push any variables down to the system
# push any variables down to the system
setup_results
=
ansible
.
runner
.
Runner
(
setup_results
=
ansible
.
runner
.
Runner
(
...
...
lib/ansible/runner.py
View file @
0935506d
...
@@ -213,6 +213,16 @@ class Runner(object):
...
@@ -213,6 +213,16 @@ class Runner(object):
args
=
[
str
(
x
)
for
x
in
module_args
]
args
=
[
str
(
x
)
for
x
in
module_args
]
args
=
" "
.
join
(
args
)
args
=
" "
.
join
(
args
)
inject_vars
=
self
.
setup_cache
.
get
(
conn
.
_host
,{})
inject_vars
=
self
.
setup_cache
.
get
(
conn
.
_host
,{})
# the metadata location for the setup module is transparently managed
# since it's an 'internals' module, kind of a black box. See playbook
# other modules are not allowed to have this kind of handling
if
remote_module_path
.
endswith
(
"/setup"
)
and
args
.
find
(
"metadata="
)
==
-
1
:
if
self
.
remote_user
==
'root'
:
args
=
"
%
s metadata=/etc/ansible/setup"
%
args
else
:
args
=
"
%
s metadata=~/.ansible/setup"
%
args
template
=
jinja2
.
Template
(
args
)
template
=
jinja2
.
Template
(
args
)
args
=
template
.
render
(
inject_vars
)
args
=
template
.
render
(
inject_vars
)
...
@@ -227,7 +237,9 @@ class Runner(object):
...
@@ -227,7 +237,9 @@ class Runner(object):
because those require extra work.
because those require extra work.
'''
'''
module
=
self
.
_transfer_module
(
conn
,
tmp
,
self
.
module_name
)
module
=
self
.
_transfer_module
(
conn
,
tmp
,
self
.
module_name
)
result
=
self
.
_execute_module
(
conn
,
tmp
,
module
,
self
.
module_args
)
result
=
self
.
_execute_module
(
conn
,
tmp
,
module
,
self
.
module_args
)
# when running the setup module, which pushes vars to the host and ALSO
# when running the setup module, which pushes vars to the host and ALSO
# returns them (+factoids), store the variables that were returned such that commands
# returns them (+factoids), store the variables that were returned such that commands
# run AFTER setup use these variables for templating when executed
# run AFTER setup use these variables for templating when executed
...
@@ -238,6 +250,7 @@ class Runner(object):
...
@@ -238,6 +250,7 @@ class Runner(object):
var_result
=
json
.
loads
(
result
)
var_result
=
json
.
loads
(
result
)
except
:
except
:
var_result
=
{}
var_result
=
{}
self
.
_delete_remote_files
(
conn
,
tmp
)
self
.
_delete_remote_files
(
conn
,
tmp
)
return
self
.
_return_from_module
(
conn
,
host
,
result
)
return
self
.
_return_from_module
(
conn
,
host
,
result
)
...
@@ -293,7 +306,13 @@ class Runner(object):
...
@@ -293,7 +306,13 @@ class Runner(object):
options
=
self
.
_parse_kv
(
self
.
module_args
)
options
=
self
.
_parse_kv
(
self
.
module_args
)
source
=
options
[
'src'
]
source
=
options
[
'src'
]
dest
=
options
[
'dest'
]
dest
=
options
[
'dest'
]
metadata
=
options
.
get
(
'metadata'
,
'/etc/ansible/setup'
)
metadata
=
options
.
get
(
'metadata'
,
None
)
if
metadata
is
None
:
if
self
.
remote_user
==
'root'
:
metadata
=
'/etc/ansible/setup'
else
:
metadata
=
'~/.ansible/setup'
# first copy the source template over
# first copy the source template over
tpath
=
tmp
tpath
=
tmp
...
...
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