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
62b39d3d
Commit
62b39d3d
authored
Jul 21, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for saving conditionals in variable expressions.
parent
ca512c7d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
7 deletions
+14
-7
CHANGELOG.md
+1
-0
lib/ansible/runner/__init__.py
+1
-2
lib/ansible/runner/action_plugins/group_by.py
+1
-1
lib/ansible/utils/__init__.py
+11
-4
No files found.
CHANGELOG.md
View file @
62b39d3d
...
@@ -89,6 +89,7 @@ Misc changes:
...
@@ -89,6 +89,7 @@ Misc changes:
*
added Jinja2 filters: skipped, whether a result was skipped
*
added Jinja2 filters: skipped, whether a result was skipped
*
added Jinja2 filters: quote, quotes a string if it needs to be quoted
*
added Jinja2 filters: quote, quotes a string if it needs to be quoted
*
allow force=yes to affect apt upgrades
*
allow force=yes to affect apt upgrades
*
fix for saving conditionals in variable names
1.
2.2 "Hear About It Later" (reprise) -- July 4, 2013
1.
2.2 "Hear About It Later" (reprise) -- July 4, 2013
...
...
lib/ansible/runner/__init__.py
View file @
62b39d3d
...
@@ -528,8 +528,7 @@ class Runner(object):
...
@@ -528,8 +528,7 @@ class Runner(object):
self
.
conditional
=
[
self
.
conditional
]
self
.
conditional
=
[
self
.
conditional
]
for
cond
in
self
.
conditional
:
for
cond
in
self
.
conditional
:
cond
=
template
.
template
(
self
.
basedir
,
cond
,
inject
,
expand_lists
=
False
)
if
not
utils
.
check_conditional
(
cond
,
self
.
basedir
,
inject
):
if
not
utils
.
check_conditional
(
cond
):
result
=
utils
.
jsonify
(
dict
(
changed
=
False
,
skipped
=
True
))
result
=
utils
.
jsonify
(
dict
(
changed
=
False
,
skipped
=
True
))
self
.
callbacks
.
on_skipped
(
host
,
inject
.
get
(
'item'
,
None
))
self
.
callbacks
.
on_skipped
(
host
,
inject
.
get
(
'item'
,
None
))
return
ReturnData
(
host
=
host
,
result
=
result
)
return
ReturnData
(
host
=
host
,
result
=
result
)
...
...
lib/ansible/runner/action_plugins/group_by.py
View file @
62b39d3d
...
@@ -58,7 +58,7 @@ class ActionModule(object):
...
@@ -58,7 +58,7 @@ class ActionModule(object):
data
=
{}
data
=
{}
data
.
update
(
inject
)
data
.
update
(
inject
)
data
.
update
(
inject
[
'hostvars'
][
host
])
data
.
update
(
inject
[
'hostvars'
][
host
])
if
not
check_conditional
(
template
.
template
(
self
.
runner
.
basedir
,
self
.
runner
.
conditional
,
data
)
):
if
not
check_conditional
(
self
.
runner
.
basedir
,
self
.
runner
.
conditional
,
data
):
continue
continue
group_name
=
template
.
template
(
self
.
runner
.
basedir
,
args
[
'key'
],
data
)
group_name
=
template
.
template
(
self
.
runner
.
basedir
,
args
[
'key'
],
data
)
group_name
=
group_name
.
replace
(
' '
,
'-'
)
group_name
=
group_name
.
replace
(
' '
,
'-'
)
...
...
lib/ansible/utils/__init__.py
View file @
62b39d3d
...
@@ -155,7 +155,16 @@ def is_changed(result):
...
@@ -155,7 +155,16 @@ def is_changed(result):
return
(
result
.
get
(
'changed'
,
False
)
in
[
True
,
'True'
,
'true'
])
return
(
result
.
get
(
'changed'
,
False
)
in
[
True
,
'True'
,
'true'
])
def
check_conditional
(
conditional
):
def
check_conditional
(
conditional
,
basedir
,
inject
):
if
conditional
.
startswith
(
"jinja2_compare"
):
conditional
=
conditional
.
replace
(
"jinja2_compare "
,
""
)
# allow variable names
if
conditional
in
inject
:
conditional
=
inject
[
conditional
]
conditional
=
template
.
template
(
basedir
,
conditional
,
inject
)
# a Jinja2 evaluation that results in something Python can eval!
presented
=
"{
%
if "
+
conditional
+
"
%
} True {
%
else
%
} False {
%
endif
%
}"
if
not
isinstance
(
conditional
,
basestring
):
if
not
isinstance
(
conditional
,
basestring
):
return
conditional
return
conditional
...
@@ -667,9 +676,7 @@ def compile_when_to_only_if(expression):
...
@@ -667,9 +676,7 @@ def compile_when_to_only_if(expression):
# the stock 'when' without qualification (new in 1.2), assumes Jinja2 terms
# the stock 'when' without qualification (new in 1.2), assumes Jinja2 terms
elif
tokens
[
0
]
==
'jinja2_compare'
:
elif
tokens
[
0
]
==
'jinja2_compare'
:
# a Jinja2 evaluation that results in something Python can eval!
return
" "
.
join
(
tokens
)
presented
=
"{
%
if "
+
" "
.
join
(
tokens
[
1
:])
.
strip
()
+
"
%
} True {
%
else
%
} False {
%
endif
%
}"
return
presented
else
:
else
:
raise
errors
.
AnsibleError
(
"invalid usage of when_ operator:
%
s"
%
expression
)
raise
errors
.
AnsibleError
(
"invalid usage of when_ operator:
%
s"
%
expression
)
...
...
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