diff --git a/bin/ansible-playbook b/bin/ansible-playbook index ba88c066a6a..cb51720d173 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -43,6 +43,12 @@ class PlaybookCallbacks(object): def on_task_start(self, name, is_conditional): print utils.task_start_msg(name, is_conditional) + def on_setup_primary(self): + print "SETUP PHASE ****************************\n" + + def on_setup_secondary(self): + print "\nVARIABLE IMPORT PHASE ******************\n" + def on_unreachable(self, host, msg): print "unreachable: [%s] => %s" % (host, msg) @@ -52,14 +58,11 @@ class PlaybookCallbacks(object): def on_ok(self, host, host_result): print "ok: [%s]\n" % (host) - def on_setup_primary(self): - print "preparing nodes..." - - def on_setup_secondary(self): - print "preparing conditional imports..." - def on_import_for_host(self, host, imported_file): - pass + print "%s: importing %s" % (host, imported_file) + + def on_not_import_for_host(self, host, missing_file): + print "%s: not importing file: %s" % (host, missing_file) def on_play_start(self, pattern): print "PLAY [%s] ****************************\n" % pattern diff --git a/examples/playbooks/playbook3.yml b/examples/playbooks/playbook3.yml index a07bb7cecc6..ed5c8eb00ad 100644 --- a/examples/playbooks/playbook3.yml +++ b/examples/playbooks/playbook3.yml @@ -32,7 +32,6 @@ - "vars/external_vars.yml" - - [ "vars/$facter_operatingsystem.yml", "vars/defaults.yml" ] # and this is just a regular task line from a playbook, as we're used to. diff --git a/lib/ansible/playbook.py b/lib/ansible/playbook.py index 2eb8297e5c3..f7d90e117bf 100755 --- a/lib/ansible/playbook.py +++ b/lib/ansible/playbook.py @@ -465,8 +465,12 @@ class PlayBook(object): SETUP_CACHE[host].update(data) self.callbacks.on_import_for_host(host, filename2) break + else: + self.callbacks.on_not_import_for_host(host, filename2) if not found: - raise errors.AnsibleError("no files matched for vars_files import sequence: %s" % sequence) + raise errors.AnsibleError( + "%s: FATAL, no files matched for vars_files import sequence: %s" % (host, sequence) + ) else: filename2 = utils.path_dwim(self.basedir, utils.template(filename, cache_vars)) @@ -508,6 +512,8 @@ class PlayBook(object): if 'failed' in host_result: self.callbacks.on_failed(host, host_result) self.failures[host] = 1 + else: + self.callbacks.on_ok(host, host_result) # now for each result, load into the setup cache so we can # let runner template out future commands diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index 28f31dfd919..6b951812810 100755 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -54,9 +54,9 @@ def smjson(result): def task_start_msg(name, conditional): if conditional: - return "NOTIFIED: [%s] **********\n" % name + return "\nNOTIFIED: [%s] **********\n" % name else: - return "TASK: [%s] *********\n" % name + return "\nTASK: [%s] *********\n" % name def regular_generic_msg(hostname, result, oneline, caption): ''' output on the result of a module run that is not command ''' diff --git a/test/TestPlayBook.py b/test/TestPlayBook.py index c741c298fa1..14560d73795 100644 --- a/test/TestPlayBook.py +++ b/test/TestPlayBook.py @@ -35,6 +35,9 @@ class TestCallbacks(object): def on_import_for_host(self, host, filename): self.events.append([ 'import', [ host, filename ]]) + def on_not_import_for_host(self, host, missing_filename): + pass + def on_task_start(self, name, is_conditional): self.events.append([ 'task start', [ name, is_conditional ]]) @@ -63,6 +66,12 @@ class TestCallbacks(object): def on_dark_host(self, host, msg): self.events.append([ 'failed/dark', [ host, msg ]]) + def on_setup_primary(self): + pass + + def on_setup_secondary(self): + pass + class TestRunner(unittest.TestCase):