|
|
@ -25,9 +25,6 @@ class TestCallbacks(object):
|
|
|
|
def on_start(self):
|
|
|
|
def on_start(self):
|
|
|
|
EVENTS.append('start')
|
|
|
|
EVENTS.append('start')
|
|
|
|
|
|
|
|
|
|
|
|
def on_setup(self):
|
|
|
|
|
|
|
|
EVENTS.append([ 'primary_setup' ])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_skipped(self, host, item=None):
|
|
|
|
def on_skipped(self, host, item=None):
|
|
|
|
EVENTS.append([ 'skipped', [ host ]])
|
|
|
|
EVENTS.append([ 'skipped', [ host ]])
|
|
|
|
|
|
|
|
|
|
|
@ -46,9 +43,6 @@ class TestCallbacks(object):
|
|
|
|
def on_task_start(self, name, is_conditional):
|
|
|
|
def on_task_start(self, name, is_conditional):
|
|
|
|
EVENTS.append([ 'task start', [ 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):
|
|
|
|
def on_failed(self, host, results, ignore_errors):
|
|
|
|
EVENTS.append([ 'failed', [ host, results, ignore_errors ]])
|
|
|
|
EVENTS.append([ 'failed', [ host, results, ignore_errors ]])
|
|
|
|
|
|
|
|
|
|
|
@ -161,6 +155,19 @@ class TestPlaybook(unittest.TestCase):
|
|
|
|
print data
|
|
|
|
print data
|
|
|
|
assert data.find("ears") != -1, "template success"
|
|
|
|
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):
|
|
|
|
def test_yaml_hosts_list(self):
|
|
|
|
# Make sure playbooks support hosts: [host1, host2]
|
|
|
|
# Make sure playbooks support hosts: [host1, host2]
|
|
|
|
# TODO: Actually run the play on more than one host
|
|
|
|
# TODO: Actually run the play on more than one host
|
|
|
|