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
1c5055a4
Commit
1c5055a4
authored
May 14, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly merge role conditionals in with pre-existing conditionals
Fixes #7387
parent
24d885e3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
15 deletions
+16
-15
lib/ansible/playbook/play.py
+16
-15
No files found.
lib/ansible/playbook/play.py
View file @
1c5055a4
...
@@ -294,26 +294,24 @@ class Play(object):
...
@@ -294,26 +294,24 @@ class Play(object):
else
:
else
:
self
.
included_roles
.
append
(
dep
)
self
.
included_roles
.
append
(
dep
)
# pass along conditionals from roles to dep roles
def
_merge_conditional
(
cur_conditionals
,
new_conditionals
):
if
type
(
role
)
is
dict
:
if
isinstance
(
new_conditionals
,
(
basestring
,
bool
))
:
if
'when'
in
passed_vars
:
cur_conditionals
.
append
(
new_conditionals
)
if
'when'
in
dep_vars
:
elif
isinstance
(
new_conditionals
,
list
)
:
tmpcond
=
[]
cur_conditionals
.
extend
(
new_conditionals
)
if
type
(
passed_vars
[
'when'
])
is
str
:
# pass along conditionals from roles to dep roles
tmpcond
.
append
(
passed_vars
[
'when'
]
)
passed_when
=
passed_vars
.
get
(
'when'
)
elif
type
(
passed_vars
[
'when'
])
is
list
:
role_when
=
role_vars
.
get
(
'when'
)
tmpcond
+=
passed_vars
[
'when'
]
dep_when
=
dep_vars
.
get
(
'when'
)
if
type
(
dep_vars
[
'when'
])
is
str
:
tmpcond
=
[]
tmpcond
.
append
(
dep_vars
[
'when'
]
)
_merge_conditional
(
tmpcond
,
passed_when
)
elif
type
(
dep_vars
[
'when'
])
is
list
:
_merge_conditional
(
tmpcond
,
role_when
)
tmpcond
+=
dep_vars
[
'when'
]
_merge_conditional
(
tmpcond
,
dep_when
)
if
len
(
tmpcond
)
>
0
:
if
len
(
tmpcond
)
>
0
:
dep_vars
[
'when'
]
=
tmpcond
dep_vars
[
'when'
]
=
tmpcond
else
:
dep_vars
[
'when'
]
=
passed_vars
[
'when'
]
self
.
_build_role_dependencies
([
dep
],
dep_stack
,
passed_vars
=
dep_vars
,
level
=
level
+
1
)
self
.
_build_role_dependencies
([
dep
],
dep_stack
,
passed_vars
=
dep_vars
,
level
=
level
+
1
)
dep_stack
.
append
([
dep
,
dep_path
,
dep_vars
,
dep_defaults_data
])
dep_stack
.
append
([
dep
,
dep_path
,
dep_vars
,
dep_defaults_data
])
...
@@ -565,7 +563,10 @@ class Play(object):
...
@@ -565,7 +563,10 @@ class Play(object):
task_vars
=
utils
.
combine_vars
(
task_vars
,
x
[
'vars'
])
task_vars
=
utils
.
combine_vars
(
task_vars
,
x
[
'vars'
])
if
'when'
in
x
:
if
'when'
in
x
:
if
isinstance
(
x
[
'when'
],
(
basestring
,
bool
)):
included_additional_conditions
.
append
(
x
[
'when'
])
included_additional_conditions
.
append
(
x
[
'when'
])
elif
isinstance
(
x
[
'when'
],
list
):
included_additional_conditions
.
extend
(
x
[
'when'
])
new_role
=
None
new_role
=
None
if
'role_name'
in
x
:
if
'role_name'
in
x
:
...
...
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