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
01139515
Commit
01139515
authored
11 years ago
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable usage of when_set within new eval system.
parent
a83e10d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
lib/ansible/runner/lookup_plugins/nested.py
+5
-0
lib/ansible/utils/__init__.py
+6
-8
No files found.
lib/ansible/runner/lookup_plugins/nested.py
View file @
01139515
...
...
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from
ansible.utils
import
safe_eval
def
flatten
(
terms
):
ret
=
[]
...
...
@@ -40,6 +41,10 @@ class LookupModule(object):
pass
def
run
(
self
,
terms
,
**
kwargs
):
if
'{'
or
'['
in
terms
:
# Jinja2-ified list needs to be converted back to a real type
# TODO: something a bit less heavy than eval
terms
=
safe_eval
(
terms
)
if
not
isinstance
(
terms
,
list
):
raise
errors
.
AnsibleError
(
"a list is required for with_nested"
)
my_list
=
terms
[:]
...
...
This diff is collapsed.
Click to expand it.
lib/ansible/utils/__init__.py
View file @
01139515
...
...
@@ -154,11 +154,6 @@ def check_conditional(conditional):
if
not
isinstance
(
conditional
,
basestring
):
return
conditional
def
is_set
(
var
):
return
not
var
.
startswith
(
"$"
)
and
not
'{{'
in
var
def
is_unset
(
var
):
return
var
.
startswith
(
"$"
)
or
'{{'
in
var
try
:
conditional
=
conditional
.
replace
(
"
\n
"
,
"
\\
n"
)
...
...
@@ -693,14 +688,17 @@ def safe_eval(str):
the env is constrained)
'''
# FIXME: is there a more native way to do this?
def
is_set
(
var
):
return
not
var
.
startswith
(
"$"
)
and
not
'{{'
in
var
def
is_unset
(
var
):
return
var
.
startswith
(
"$"
)
or
'{{'
in
var
# do not allow method calls
# do not allow method calls
to modules
if
re
.
search
(
r'\w\.\w+\('
,
str
):
print
"C1"
return
str
# do not allow imports
if
re
.
search
(
r'import \w+'
,
str
):
print
"C2"
return
str
return
eval
(
str
)
...
...
This diff is collapsed.
Click to expand it.
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