Add new meta task end_host (#47194)

* Add new meta task  end_host
This commit is contained in:
Martin Krizek
2018-11-14 15:46:25 +01:00
committed by Brian Coca
parent 24593f2ffb
commit 907ff2f26c
8 changed files with 69 additions and 2 deletions

View File

@@ -0,0 +1 @@
shippable/posix/group3

View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -eux
# test end_host meta task, with when conditional
for test_strategy in linear free; do
out="$(ansible-playbook test_end_host.yml -i ../../inventory -e test_strategy=$test_strategy -vv "$@")"
grep -q "META: end_host conditional evaluated to false, continuing execution for testhost" <<< "$out"
grep -q "META: ending play for testhost2" <<< "$out"
grep -q "play not ended for testhost" <<< "$out"
grep -qv "play not ended for testhost2" <<< "$out"
done
# test end_host meta task, on all hosts
for test_strategy in linear free; do
out="$(ansible-playbook test_end_host_all.yml -i ../../inventory -e test_strategy=$test_strategy -vv "$@")"
grep -q "META: ending play for testhost" <<< "$out"
grep -q "META: ending play for testhost2" <<< "$out"
grep -qv "play not ended for testhost" <<< "$out"
grep -qv "play not ended for testhost2" <<< "$out"
done

View File

@@ -0,0 +1,14 @@
- name: "Testing end_host with strategy={{ test_strategy | default('linear') }}"
hosts:
- testhost
- testhost2
gather_facts: no
strategy: "{{ test_strategy | default('linear') }}"
tasks:
- debug:
- meta: end_host
when: "host_var_role_name == 'role2'" # end play for testhost2, see test/integration/inventory
- debug:
msg: "play not ended for {{ inventory_hostname }}"

View File

@@ -0,0 +1,13 @@
- name: "Testing end_host all hosts with strategy={{ test_strategy | default('linear') }}"
hosts:
- testhost
- testhost2
gather_facts: no
strategy: "{{ test_strategy | default('linear') }}"
tasks:
- debug:
- meta: end_host
- debug:
msg: "play not ended {{ inventory_hostname }}"