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
4664e354
Commit
4664e354
authored
May 26, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get with_items to work with new play/task architecture.
parent
ecb94489
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
9 deletions
+25
-9
lib/ansible/playbook/play.py
+16
-6
lib/ansible/playbook/task.py
+9
-3
No files found.
lib/ansible/playbook/play.py
View file @
4664e354
...
...
@@ -80,13 +80,23 @@ class Play(object):
include_file
=
tokens
[
0
]
data
=
utils
.
parse_yaml_from_file
(
utils
.
path_dwim
(
self
.
playbook
.
basedir
,
include_file
))
for
y
in
data
:
t
=
Task
(
self
,
y
)
# TODO: rename this to just 'vars'
t
.
module_vars
=
self
.
vars
.
copy
()
t
.
module_vars
.
update
(
task_vars
)
results
.
append
(
t
)
items
=
y
.
get
(
'with_items'
,
None
)
if
items
is
None
:
items
=
[
''
]
for
item
in
items
:
t
=
Task
(
self
,
y
)
mv
=
self
.
vars
.
copy
()
mv
.
update
(
task_vars
)
mv
[
'item'
]
=
item
results
.
append
(
Task
(
self
,
y
,
module_vars
=
mv
))
elif
type
(
x
)
==
dict
:
results
.
append
(
Task
(
self
,
x
))
items
=
x
.
get
(
'with_items'
,
None
)
if
items
is
None
:
items
=
[
''
]
for
item
in
items
:
mv
=
self
.
vars
.
copy
()
mv
[
'item'
]
=
item
results
.
append
(
Task
(
self
,
x
,
module_vars
=
mv
))
else
:
raise
Exception
(
"unexpected task type"
)
return
results
...
...
lib/ansible/playbook/task.py
View file @
4664e354
...
...
@@ -18,6 +18,7 @@
#############################################
from
ansible
import
errors
from
ansible
import
utils
class
Task
(
object
):
...
...
@@ -26,10 +27,13 @@ class Task(object):
'notify'
,
'module_name'
,
'module_args'
,
'module_vars'
,
'play'
,
'notified_by'
,
]
def
__init__
(
self
,
play
,
ds
):
def
__init__
(
self
,
play
,
ds
,
module_vars
=
None
):
''' constructor loads from a task or handler datastructure '''
# TODO: more error handling
# include task specific vars
self
.
module_vars
=
module_vars
self
.
play
=
play
self
.
name
=
ds
.
get
(
'name'
,
None
)
...
...
@@ -55,8 +59,10 @@ class Task(object):
if
len
(
tokens
)
>
1
:
self
.
module_args
=
tokens
[
1
]
# include task specific vars
self
.
module_vars
=
ds
.
get
(
'vars'
,
{})
self
.
name
=
utils
.
template
(
self
.
name
,
self
.
module_vars
)
self
.
action
=
utils
.
template
(
self
.
name
,
self
.
module_vars
)
if
'first_available_file'
in
ds
:
self
.
module_vars
[
'first_available_file'
]
=
ds
.
get
(
'first_available_file'
)
...
...
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