From baf868f82504def5f62bec2d9a67533371c658c5 Mon Sep 17 00:00:00 2001 From: Stoned Elipot Date: Mon, 1 Jul 2013 02:31:16 +0200 Subject: [PATCH] Add test for 'ignore_errors:' --- test/TestPlayBook.py | 28 ++++++++++++++++++++++++++++ test/playbook-ignore-errors.yml | 9 +++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/playbook-ignore-errors.yml diff --git a/test/TestPlayBook.py b/test/TestPlayBook.py index 1b54ce39de..5b44302af0 100644 --- a/test/TestPlayBook.py +++ b/test/TestPlayBook.py @@ -354,6 +354,34 @@ class TestPlaybook(unittest.TestCase): # restore default hash behavior C.DEFAULT_HASH_BEHAVIOUR = saved_hash_behavior + def test_playbook_ignore_errors(self): + test_callbacks = TestCallbacks() + playbook = ansible.playbook.PlayBook( + playbook=os.path.join(self.test_dir, 'playbook-ignore-errors.yml'), + host_list='test/ansible_hosts', + stats=ans_callbacks.AggregateStats(), + callbacks=test_callbacks, + runner_callbacks=test_callbacks + ) + actual = playbook.run() + + # if different, this will output to screen + print "**ACTUAL**" + print utils.jsonify(actual, format=True) + expected = { + "localhost": { + "changed": 1, + "failures": 1, + "ok": 1, + "skipped": 0, + "unreachable": 0 + } + } + print "**EXPECTED**" + print utils.jsonify(expected, format=True) + + assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True) + def _compare_file_output(self, filename, expected_lines): actual_lines = [] with open(filename) as f: diff --git a/test/playbook-ignore-errors.yml b/test/playbook-ignore-errors.yml new file mode 100644 index 0000000000..02820f855f --- /dev/null +++ b/test/playbook-ignore-errors.yml @@ -0,0 +1,9 @@ +--- +- hosts: all + connection: local + gather_facts: False + + tasks: + - action: command false + ignore_errors: true + - action: command false