Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for 'ignore_errors:' #3387

Merged
merged 1 commit into from
Jul 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/TestPlayBook.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,34 @@ def test_playbook_hash_merge(self):
# 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:
Expand Down
9 changes: 9 additions & 0 deletions test/playbook-ignore-errors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- hosts: all
connection: local
gather_facts: False

tasks:
- action: command false
ignore_errors: true
- action: command false