mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Always load group_vars and host_vars.
This commit is contained in:
@@ -25,9 +25,6 @@ class TestCallbacks(object):
|
||||
def on_start(self):
|
||||
EVENTS.append('start')
|
||||
|
||||
def on_setup(self):
|
||||
EVENTS.append([ 'primary_setup' ])
|
||||
|
||||
def on_skipped(self, host, item=None):
|
||||
EVENTS.append([ 'skipped', [ host ]])
|
||||
|
||||
@@ -46,9 +43,6 @@ class TestCallbacks(object):
|
||||
def on_task_start(self, name, is_conditional):
|
||||
EVENTS.append([ 'task start', [ name, is_conditional ]])
|
||||
|
||||
def on_unreachable(self, host, msg):
|
||||
EVENTS.append([ 'unreachable', [ host, msg ]])
|
||||
|
||||
def on_failed(self, host, results, ignore_errors):
|
||||
EVENTS.append([ 'failed', [ host, results, ignore_errors ]])
|
||||
|
||||
@@ -161,6 +155,19 @@ class TestPlaybook(unittest.TestCase):
|
||||
print data
|
||||
assert data.find("ears") != -1, "template success"
|
||||
|
||||
def test_playbook_vars(self):
|
||||
test_callbacks = TestCallbacks()
|
||||
playbook = ansible.playbook.PlayBook(
|
||||
playbook=os.path.join(self.test_dir, 'test_playbook_vars', 'playbook.yml'),
|
||||
host_list='test/test_playbook_vars/hosts',
|
||||
stats=ans_callbacks.AggregateStats(),
|
||||
callbacks=test_callbacks,
|
||||
runner_callbacks=test_callbacks
|
||||
)
|
||||
playbook.run()
|
||||
assert playbook.SETUP_CACHE['host1'] == {'attr2': 2, 'attr1': 1}
|
||||
assert playbook.SETUP_CACHE['host2'] == {'attr2': 2}
|
||||
|
||||
def test_yaml_hosts_list(self):
|
||||
# Make sure playbooks support hosts: [host1, host2]
|
||||
# TODO: Actually run the play on more than one host
|
||||
|
||||
2
test/test_playbook_vars/group_vars/group
Normal file
2
test/test_playbook_vars/group_vars/group
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
attr2: 2
|
||||
2
test/test_playbook_vars/host_vars/host1
Normal file
2
test/test_playbook_vars/host_vars/host1
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
attr1: 1
|
||||
6
test/test_playbook_vars/hosts
Normal file
6
test/test_playbook_vars/hosts
Normal file
@@ -0,0 +1,6 @@
|
||||
host1
|
||||
host2
|
||||
|
||||
[group]
|
||||
host1
|
||||
host2
|
||||
2
test/test_playbook_vars/playbook.yml
Normal file
2
test/test_playbook_vars/playbook.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- hosts: group
|
||||
Reference in New Issue
Block a user