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
8bb8314d
Commit
8bb8314d
authored
Jul 17, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inject vars need to pushed further up to make with_items work as desired.
parent
4e74ab48
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
lib/ansible/playbook/task.py
+0
-4
lib/ansible/runner/__init__.py
+19
-11
No files found.
lib/ansible/playbook/task.py
View file @
8bb8314d
...
...
@@ -95,10 +95,6 @@ class Task(object):
# process with_items so it can be used by Runner code
if
self
.
with_items
is
None
:
self
.
with_items
=
[
]
elif
isinstance
(
self
.
with_items
,
basestring
):
self
.
with_items
=
utils
.
varLookup
(
self
.
with_items
,
self
.
module_vars
)
if
type
(
self
.
with_items
)
!=
list
:
raise
errors
.
AnsibleError
(
"with_items must be a list, got:
%
s"
%
self
.
with_items
)
self
.
module_vars
[
'items'
]
=
self
.
with_items
# tags allow certain parts of a playbook to be run without running the whole playbook
...
...
lib/ansible/runner/__init__.py
View file @
8bb8314d
...
...
@@ -548,9 +548,24 @@ class Runner(object):
def
_executor_internal
(
self
,
host
):
''' executes any module one or more times '''
host_variables
=
self
.
inventory
.
get_variables
(
host
)
port
=
host_variables
.
get
(
'ansible_ssh_port'
,
self
.
remote_port
)
inject
=
self
.
setup_cache
[
host
]
.
copy
()
inject
.
update
(
host_variables
)
inject
.
update
(
self
.
module_vars
)
items
=
self
.
module_vars
.
get
(
'items'
,
[])
if
isinstance
(
items
,
basestring
)
and
items
.
startswith
(
"$"
):
items
=
items
.
replace
(
"$"
,
""
)
if
items
in
inject
:
items
=
inject
[
items
]
else
:
raise
errors
.
AnsibleError
(
"unbound variable in with_items:
%
s"
%
items
)
if
type
(
items
)
!=
list
:
raise
errors
.
AnsibleError
(
"with_items only takes a list:
%
s"
%
items
)
if
len
(
items
)
==
0
:
return
self
.
_executor_internal_inner
(
host
)
return
self
.
_executor_internal_inner
(
host
,
inject
,
port
)
else
:
# executing using with_items, so make multiple calls
# TODO: refactor
...
...
@@ -560,8 +575,8 @@ class Runner(object):
all_failed
=
False
results
=
[]
for
x
in
items
:
self
.
module_vars
[
'item'
]
=
x
result
=
self
.
_executor_internal_inner
(
host
)
inject
[
'item'
]
=
x
result
=
self
.
_executor_internal_inner
(
host
,
inject
,
port
)
results
.
append
(
result
.
result
)
if
result
.
comm_ok
==
False
:
all_comm_ok
=
False
...
...
@@ -582,16 +597,9 @@ class Runner(object):
# *****************************************************
def
_executor_internal_inner
(
self
,
host
):
def
_executor_internal_inner
(
self
,
host
,
inject
,
port
):
''' decides how to invoke a module '''
host_variables
=
self
.
inventory
.
get_variables
(
host
)
port
=
host_variables
.
get
(
'ansible_ssh_port'
,
self
.
remote_port
)
inject
=
self
.
setup_cache
[
host
]
.
copy
()
inject
.
update
(
host_variables
)
inject
.
update
(
self
.
module_vars
)
# special non-user/non-fact variables:
# 'groups' variable is a list of host name in each group
# 'hostvars' variable contains variables for each host name
...
...
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