mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Merge branch 'always_run-6' of https://github.com/stoned/ansible into stoned-always_run-6
This commit is contained in:
@@ -474,6 +474,37 @@ class TestPlaybook(unittest.TestCase):
|
||||
|
||||
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
|
||||
|
||||
|
||||
def test_playbook_always_run(self):
|
||||
test_callbacks = TestCallbacks()
|
||||
playbook = ansible.playbook.PlayBook(
|
||||
playbook=os.path.join(self.test_dir, 'playbook-always-run.yml'),
|
||||
host_list='test/ansible_hosts',
|
||||
stats=ans_callbacks.AggregateStats(),
|
||||
callbacks=test_callbacks,
|
||||
runner_callbacks=test_callbacks,
|
||||
check=True
|
||||
)
|
||||
actual = playbook.run()
|
||||
|
||||
# if different, this will output to screen
|
||||
print "**ACTUAL**"
|
||||
print utils.jsonify(actual, format=True)
|
||||
expected = {
|
||||
"localhost": {
|
||||
"changed": 4,
|
||||
"failures": 0,
|
||||
"ok": 4,
|
||||
"skipped": 8,
|
||||
"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:
|
||||
|
||||
48
test/playbook-always-run.yml
Normal file
48
test/playbook-always-run.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
- hosts: all
|
||||
connection: local
|
||||
gather_facts: False
|
||||
vars:
|
||||
var_true: True
|
||||
var_false: False
|
||||
var_empty_str: "''"
|
||||
var_null: ~
|
||||
|
||||
tasks:
|
||||
- action: command echo ping
|
||||
always_run: yes
|
||||
|
||||
- action: command echo pong 1
|
||||
|
||||
- action: command echo pong 2
|
||||
always_run: no
|
||||
|
||||
- action: command echo pong 3
|
||||
always_run: 1 + 1
|
||||
|
||||
- action: command echo pong 4
|
||||
always_run: "''"
|
||||
|
||||
- action: command echo pong 5
|
||||
always_run: False
|
||||
|
||||
- action: command echo pong 6
|
||||
always_run: True
|
||||
|
||||
- action: command echo pong 7
|
||||
always_run: var_true
|
||||
|
||||
- action: command echo pong 8
|
||||
always_run: var_false
|
||||
|
||||
- action: command echo pong 9
|
||||
always_run: var_empty_str
|
||||
|
||||
- action: command echo pong 10
|
||||
always_run: var_null
|
||||
|
||||
# this will never run...
|
||||
- action: command echo pong 11
|
||||
always_run: yes
|
||||
when: no
|
||||
|
||||
Reference in New Issue
Block a user