mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Add parameterized playbook includes
Also makes with_* work with them. Fixes #1162.
This commit is contained in:
@@ -204,6 +204,27 @@ class TestPlaybook(unittest.TestCase):
|
||||
|
||||
assert len(EVENTS) == 44
|
||||
|
||||
def test_includes(self):
|
||||
pb = os.path.join(self.test_dir, 'playbook-includer.yml')
|
||||
actual = self._run(pb)
|
||||
|
||||
# if different, this will output to screen
|
||||
print "**ACTUAL**"
|
||||
print utils.jsonify(actual, format=True)
|
||||
expected = {
|
||||
"localhost": {
|
||||
"changed": 0,
|
||||
"failures": 0,
|
||||
"ok": 5,
|
||||
"skipped": 0,
|
||||
"unreachable": 0
|
||||
}
|
||||
}
|
||||
print "**EXPECTED**"
|
||||
print utils.jsonify(expected, format=True)
|
||||
|
||||
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
|
||||
|
||||
def test_playbook_vars(self):
|
||||
test_callbacks = TestCallbacks()
|
||||
playbook = ansible.playbook.PlayBook(
|
||||
|
||||
5
test/playbook-included.yml
Normal file
5
test/playbook-included.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- hosts: all
|
||||
gather_facts: False
|
||||
tasks:
|
||||
- action: debug msg="$variable"
|
||||
8
test/playbook-includer.yml
Normal file
8
test/playbook-includer.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- include: playbook-included.yml variable=foobar
|
||||
- include: playbook-included.yml variable=foofoo
|
||||
- include: playbook-included.yml variable=$item
|
||||
with_items:
|
||||
- foo
|
||||
- bar
|
||||
- baz
|
||||
Reference in New Issue
Block a user