mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add test for 'ignore_errors:'
This commit is contained in:
parent
c2988dfdb0
commit
baf868f825
2 changed files with 37 additions and 0 deletions
|
@ -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:
|
||||
|
|
9
test/playbook-ignore-errors.yml
Normal file
9
test/playbook-ignore-errors.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- hosts: all
|
||||
connection: local
|
||||
gather_facts: False
|
||||
|
||||
tasks:
|
||||
- action: command false
|
||||
ignore_errors: true
|
||||
- action: command false
|
Loading…
Reference in a new issue