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
695b4bcb
Commit
695b4bcb
authored
Oct 01, 2012
by
Daniel Hokka Zakrisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow non-string types in with_items variables
parent
886a1785
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletions
+40
-1
lib/ansible/utils.py
+1
-1
test/TestUtils.py
+39
-0
No files found.
lib/ansible/utils.py
View file @
695b4bcb
...
...
@@ -371,7 +371,7 @@ def varReplaceWithItems(basedir, varname, vars):
d
[
k
]
=
varReplaceWithItems
(
basedir
,
v
,
vars
)
return
d
else
:
r
aise
Exception
(
"invalid with_items type"
)
r
eturn
varname
def
template
(
basedir
,
text
,
vars
):
...
...
test/TestUtils.py
View file @
695b4bcb
...
...
@@ -250,6 +250,45 @@ class TestUtils(unittest.TestCase):
assert
res
==
u'hello world'
#####################################
### varReplaceWithItems function tests
def
test_varReplaceWithItems_basic
(
self
):
vars
=
{
'data'
:
{
'var'
:
[
'foo'
,
'bar'
,
'baz'
,
],
'types'
:
[
'str'
,
u'unicode'
,
1
,
1L
,
1.2
,
],
'alphas'
:
'$alphas'
,
},
'alphas'
:
[
'abc'
,
'def'
,
'ghi'
,
],
}
template
=
'${data.var}'
res
=
ansible
.
utils
.
varReplaceWithItems
(
None
,
template
,
vars
)
assert
sorted
(
res
)
==
sorted
(
vars
[
'data'
][
'var'
])
template
=
'${data.types}'
res
=
ansible
.
utils
.
varReplaceWithItems
(
None
,
template
,
vars
)
assert
sorted
(
res
)
==
sorted
(
vars
[
'data'
][
'types'
])
template
=
'${data.alphas}'
res
=
ansible
.
utils
.
varReplaceWithItems
(
None
,
template
,
vars
)
assert
sorted
(
res
)
==
sorted
(
vars
[
'alphas'
])
#####################################
### Template function tests
def
test_template_basic
(
self
):
...
...
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