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
4a732c1e
Commit
4a732c1e
authored
Jul 18, 2013
by
Tin Tvrtkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enabled the use of extra vars in playbook file paths when including playbooks from other playbooks.
parent
c3a8b6ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
lib/ansible/playbook/__init__.py
+1
-1
test/TestPlayBook.py
+26
-1
test/playbook-templated-includer.yml
+3
-0
No files found.
lib/ansible/playbook/__init__.py
View file @
4a732c1e
...
...
@@ -130,7 +130,7 @@ class PlayBook(object):
self
.
basedir
=
os
.
path
.
dirname
(
playbook
)
or
'.'
utils
.
plugins
.
push_basedir
(
self
.
basedir
)
vars
=
{}
vars
=
extra_vars
.
copy
()
if
self
.
inventory
.
basedir
()
is
not
None
:
vars
[
'inventory_dir'
]
=
self
.
inventory
.
basedir
()
self
.
filename
=
playbook
...
...
test/TestPlayBook.py
View file @
4a732c1e
...
...
@@ -119,7 +119,8 @@ class TestPlaybook(unittest.TestCase):
filename
=
os
.
path
.
join
(
self
.
stage_dir
,
filename
)
return
filename
def
_run
(
self
,
test_playbook
,
host_list
=
'test/ansible_hosts'
):
def
_run
(
self
,
test_playbook
,
host_list
=
'test/ansible_hosts'
,
extra_vars
=
None
):
''' run a module and get the localhost results '''
# This ensures tests are independent of eachother
global
EVENTS
...
...
@@ -135,6 +136,7 @@ class TestPlaybook(unittest.TestCase):
timeout
=
5
,
remote_user
=
self
.
user
,
remote_pass
=
None
,
extra_vars
=
extra_vars
,
stats
=
ans_callbacks
.
AggregateStats
(),
callbacks
=
self
.
test_callbacks
,
runner_callbacks
=
self
.
test_callbacks
...
...
@@ -216,6 +218,29 @@ class TestPlaybook(unittest.TestCase):
assert
utils
.
jsonify
(
expected
,
format
=
True
)
==
utils
.
jsonify
(
actual
,
format
=
True
)
def
test_templated_includes
(
self
):
pb
=
os
.
path
.
join
(
self
.
test_dir
,
'playbook-templated-includer.yml'
)
actual
=
self
.
_run
(
pb
,
extra_vars
=
{
'dir'
:
self
.
test_dir
})
# if different, this will output to screen
print
"**ACTUAL**"
actual_json
=
utils
.
jsonify
(
actual
,
format
=
True
)
print
actual_json
expected
=
{
"localhost"
:
{
"changed"
:
0
,
"failures"
:
0
,
"ok"
:
2
,
"skipped"
:
0
,
"unreachable"
:
0
}
}
expected_json
=
utils
.
jsonify
(
expected
,
format
=
True
)
print
"**EXPECTED**"
print
expected_json
assert
actual_json
==
expected_json
def
test_task_includes
(
self
):
pb
=
os
.
path
.
join
(
self
.
test_dir
,
'task-includer.yml'
)
actual
=
self
.
_run
(
pb
)
...
...
test/playbook-templated-includer.yml
0 → 100644
View file @
4a732c1e
---
-
include
:
"
{{dir}}/playbook-included.yml
variable=foobar"
\ No newline at end of file
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