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
d181a643
Commit
d181a643
authored
Sep 25, 2012
by
Daniel Hokka Zakrisson
Committed by
Michael DeHaan
Sep 25, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use repr on replacements for only_if
parent
489844f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
lib/ansible/runner/__init__.py
+1
-1
lib/ansible/utils.py
+10
-3
No files found.
lib/ansible/runner/__init__.py
View file @
d181a643
...
...
@@ -317,7 +317,7 @@ class Runner(object):
new_args
=
new_args
+
"
%
s='
%
s' "
%
(
k
,
v
)
module_args
=
new_args
conditional
=
utils
.
template
(
self
.
basedir
,
self
.
conditional
,
inject
)
conditional
=
utils
.
template
(
self
.
basedir
,
self
.
conditional
,
inject
,
do_repr
=
True
)
if
not
utils
.
check_conditional
(
conditional
):
result
=
utils
.
jsonify
(
dict
(
skipped
=
True
))
self
.
callbacks
.
on_skipped
(
host
,
inject
.
get
(
'item'
,
None
))
...
...
lib/ansible/utils.py
View file @
d181a643
...
...
@@ -209,7 +209,7 @@ def varLookup(varname, vars):
except
VarNotFoundException
:
return
None
def
varReplace
(
raw
,
vars
):
def
varReplace
(
raw
,
vars
,
do_repr
=
False
):
''' Perform variable replacement of $variables in string raw using vars dictionary '''
# this code originally from yum
...
...
@@ -230,6 +230,13 @@ def varReplace(raw, vars):
replacement
=
m
.
group
()
start
,
end
=
m
.
span
()
if
do_repr
:
replacement
=
repr
(
replacement
)
if
(
start
>
0
and
((
raw
[
start
-
1
]
==
"'"
and
raw
[
end
]
==
"'"
)
or
(
raw
[
start
-
1
]
==
'"'
and
raw
[
end
]
==
'"'
))):
start
-=
1
end
+=
1
done
.
append
(
raw
[:
start
])
# Keep stuff leading up to token
done
.
append
(
replacement
)
# Append replacement value
raw
=
raw
[
end
:]
# Continue with remainder of string
...
...
@@ -271,7 +278,7 @@ def varReplaceFilesAndPipes(basedir, raw):
return
''
.
join
(
done
)
def
template
(
basedir
,
text
,
vars
):
def
template
(
basedir
,
text
,
vars
,
do_repr
=
False
):
''' run a text buffer through the templating engine until it no longer changes '''
prev_text
=
''
...
...
@@ -285,7 +292,7 @@ def template(basedir, text, vars):
if
(
depth
>
20
):
raise
errors
.
AnsibleError
(
"template recursion depth exceeded"
)
prev_text
=
text
text
=
varReplace
(
unicode
(
text
),
vars
)
text
=
varReplace
(
unicode
(
text
),
vars
,
do_repr
)
text
=
varReplaceFilesAndPipes
(
basedir
,
text
)
return
text
...
...
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