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
dfa33d0f
Commit
dfa33d0f
authored
Sep 30, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak variable manager use in role includes to avoid test failures
parent
a89412ec
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
+18
-7
lib/ansible/playbook/role/definition.py
+9
-2
test/units/executor/test_play_iterator.py
+5
-4
test/units/playbook/test_play.py
+4
-1
No files found.
lib/ansible/playbook/role/definition.py
View file @
dfa33d0f
...
@@ -159,9 +159,16 @@ class RoleDefinition(Base, Become, Conditional, Taggable):
...
@@ -159,9 +159,16 @@ class RoleDefinition(Base, Become, Conditional, Taggable):
if
self
.
_role_basedir
:
if
self
.
_role_basedir
:
role_search_paths
.
append
(
self
.
_role_basedir
)
role_search_paths
.
append
(
self
.
_role_basedir
)
# now iterate through the possible paths and return the first one we find
# create a templar class to template the dependency names, in
all_vars
=
self
.
_variable_manager
.
get_vars
(
loader
=
self
.
_loader
,
play
=
self
.
_play
)
# case they contain variables
if
self
.
_variable_manager
is
not
None
:
all_vars
=
self
.
_variable_manager
.
get_vars
(
loader
=
self
.
_loader
,
play
=
self
.
_play
)
else
:
all_vars
=
dict
()
templar
=
Templar
(
loader
=
self
.
_loader
,
variables
=
all_vars
)
templar
=
Templar
(
loader
=
self
.
_loader
,
variables
=
all_vars
)
# now iterate through the possible paths and return the first one we find
for
path
in
role_search_paths
:
for
path
in
role_search_paths
:
path
=
templar
.
template
(
path
)
path
=
templar
.
template
(
path
)
role_path
=
unfrackpath
(
os
.
path
.
join
(
path
,
role_name
))
role_path
=
unfrackpath
(
os
.
path
.
join
(
path
,
role_name
))
...
...
test/units/executor/test_play_iterator.py
View file @
dfa33d0f
...
@@ -56,7 +56,11 @@ class TestPlayIterator(unittest.TestCase):
...
@@ -56,7 +56,11 @@ class TestPlayIterator(unittest.TestCase):
"""
,
"""
,
})
})
p
=
Playbook
.
load
(
'test_play.yml'
,
loader
=
fake_loader
)
mock_var_manager
=
MagicMock
()
mock_var_manager
.
_fact_cache
=
dict
()
mock_var_manager
.
get_vars
.
return_value
=
dict
()
p
=
Playbook
.
load
(
'test_play.yml'
,
loader
=
fake_loader
,
variable_manager
=
mock_var_manager
)
hosts
=
[]
hosts
=
[]
for
i
in
range
(
0
,
10
):
for
i
in
range
(
0
,
10
):
...
@@ -68,9 +72,6 @@ class TestPlayIterator(unittest.TestCase):
...
@@ -68,9 +72,6 @@ class TestPlayIterator(unittest.TestCase):
inventory
.
get_hosts
.
return_value
=
hosts
inventory
.
get_hosts
.
return_value
=
hosts
inventory
.
filter_hosts
.
return_value
=
hosts
inventory
.
filter_hosts
.
return_value
=
hosts
mock_var_manager
=
MagicMock
()
mock_var_manager
.
_fact_cache
=
dict
()
play_context
=
PlayContext
(
play
=
p
.
_entries
[
0
])
play_context
=
PlayContext
(
play
=
p
.
_entries
[
0
])
itr
=
PlayIterator
(
itr
=
PlayIterator
(
...
...
test/units/playbook/test_play.py
View file @
dfa33d0f
...
@@ -110,12 +110,15 @@ class TestPlay(unittest.TestCase):
...
@@ -110,12 +110,15 @@ class TestPlay(unittest.TestCase):
"""
,
"""
,
})
})
mock_var_manager
=
MagicMock
()
mock_var_manager
.
get_vars
.
return_value
=
dict
()
p
=
Play
.
load
(
dict
(
p
=
Play
.
load
(
dict
(
name
=
"test play"
,
name
=
"test play"
,
hosts
=
[
'foo'
],
hosts
=
[
'foo'
],
gather_facts
=
False
,
gather_facts
=
False
,
roles
=
[
'foo'
],
roles
=
[
'foo'
],
),
loader
=
fake_loader
)
),
loader
=
fake_loader
,
variable_manager
=
mock_var_manager
)
blocks
=
p
.
compile
()
blocks
=
p
.
compile
()
...
...
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