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
2b500568
Commit
2b500568
authored
Nov 05, 2013
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #4635 pass role conditionals to dependent roles
parent
b87e0e59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletions
+26
-1
lib/ansible/playbook/play.py
+26
-1
No files found.
lib/ansible/playbook/play.py
View file @
2b500568
...
@@ -251,6 +251,27 @@ class Play(object):
...
@@ -251,6 +251,27 @@ class Play(object):
else
:
else
:
self
.
included_roles
.
append
(
dep
)
self
.
included_roles
.
append
(
dep
)
# pass along conditionals from roles to dep roles
if
type
(
role
)
is
dict
:
if
'when'
in
passed_vars
:
if
'when'
in
dep_vars
:
tmpcond
=
[]
if
type
(
passed_vars
[
'when'
])
is
str
:
tmpcond
.
append
(
passed_vars
[
'when'
])
elif
type
(
passed_vars
[
'when'
])
is
list
:
tmpcond
.
join
(
passed_vars
[
'when'
])
if
type
(
dep_vars
[
'when'
])
is
str
:
tmpcond
.
append
(
dep_vars
[
'when'
])
elif
type
(
dep_vars
[
'when'
])
is
list
:
tmpcond
.
join
(
dep_vars
[
'when'
])
if
len
(
tmpcond
)
>
0
:
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
])
...
@@ -467,7 +488,11 @@ class Play(object):
...
@@ -467,7 +488,11 @@ class Play(object):
elif
k
.
startswith
(
"when_"
):
elif
k
.
startswith
(
"when_"
):
included_additional_conditions
.
insert
(
0
,
utils
.
compile_when_to_only_if
(
"
%
s
%
s"
%
(
k
[
5
:],
x
[
k
])))
included_additional_conditions
.
insert
(
0
,
utils
.
compile_when_to_only_if
(
"
%
s
%
s"
%
(
k
[
5
:],
x
[
k
])))
elif
k
==
'when'
:
elif
k
==
'when'
:
included_additional_conditions
.
insert
(
0
,
utils
.
compile_when_to_only_if
(
"jinja2_compare
%
s"
%
x
[
k
]))
if
type
(
x
[
k
])
is
str
:
included_additional_conditions
.
insert
(
0
,
utils
.
compile_when_to_only_if
(
"jinja2_compare
%
s"
%
x
[
k
]))
elif
type
(
x
[
k
])
is
list
:
for
i
in
x
[
k
]:
included_additional_conditions
.
insert
(
0
,
utils
.
compile_when_to_only_if
(
"jinja2_compare
%
s"
%
i
))
elif
k
in
(
"include"
,
"vars"
,
"default_vars"
,
"only_if"
,
"sudo"
,
"sudo_user"
,
"role_name"
):
elif
k
in
(
"include"
,
"vars"
,
"default_vars"
,
"only_if"
,
"sudo"
,
"sudo_user"
,
"role_name"
):
continue
continue
else
:
else
:
...
...
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