summaryrefslogtreecommitdiff
path: root/test/integration/targets/special_vars_hosts
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2021-05-11 11:12:34 -0400
committerGitHub <noreply@github.com>2021-05-11 17:12:34 +0200
commitcf11c38cafc88ec301f48f9673ec1f554e82a589 (patch)
treeb52b8e32bd97af95281f770f1e219c09ae731ac6 /test/integration/targets/special_vars_hosts
parentdf6554c4ec8b1256067bc2510134ac49cfc3003c (diff)
downloadansible-cf11c38cafc88ec301f48f9673ec1f554e82a589.tar.gz
Exclude unreachable hosts in ansible_play_batch between plays (#74625)
ci_complete
Diffstat (limited to 'test/integration/targets/special_vars_hosts')
-rw-r--r--test/integration/targets/special_vars_hosts/aliases1
-rw-r--r--test/integration/targets/special_vars_hosts/inventory3
-rw-r--r--test/integration/targets/special_vars_hosts/playbook.yml53
-rwxr-xr-xtest/integration/targets/special_vars_hosts/runme.sh7
4 files changed, 64 insertions, 0 deletions
diff --git a/test/integration/targets/special_vars_hosts/aliases b/test/integration/targets/special_vars_hosts/aliases
new file mode 100644
index 0000000000..70a7b7a9f3
--- /dev/null
+++ b/test/integration/targets/special_vars_hosts/aliases
@@ -0,0 +1 @@
+shippable/posix/group5
diff --git a/test/integration/targets/special_vars_hosts/inventory b/test/integration/targets/special_vars_hosts/inventory
new file mode 100644
index 0000000000..8d69e574eb
--- /dev/null
+++ b/test/integration/targets/special_vars_hosts/inventory
@@ -0,0 +1,3 @@
+successful ansible_connection=local ansible_host=127.0.0.1 ansible_python_interpreter="{{ ansible_playbook_python }}"
+failed ansible_connection=local ansible_host=127.0.0.1 ansible_python_interpreter="{{ ansible_playbook_python }}"
+unreachable ansible_connection=ssh ansible_host=127.0.0.1 ansible_port=1011 # IANA Reserved port
diff --git a/test/integration/targets/special_vars_hosts/playbook.yml b/test/integration/targets/special_vars_hosts/playbook.yml
new file mode 100644
index 0000000000..e3d9e43541
--- /dev/null
+++ b/test/integration/targets/special_vars_hosts/playbook.yml
@@ -0,0 +1,53 @@
+---
+- hosts: all
+ gather_facts: no
+ tasks:
+ - name: test magic vars for hosts without any failed/unreachable (no serial)
+ assert:
+ that:
+ - ansible_play_batch | length == 3
+ - ansible_play_hosts | length == 3
+ - ansible_play_hosts_all | length == 3
+ run_once: True
+
+ - ping:
+ failed_when: "inventory_hostname == 'failed'"
+
+ - meta: clear_host_errors
+
+- hosts: all
+ gather_facts: no
+ tasks:
+ - name: test host errors were cleared
+ assert:
+ that:
+ - ansible_play_batch | length == 3
+ - ansible_play_hosts | length == 3
+ - ansible_play_hosts_all | length == 3
+ run_once: True
+
+ - ping:
+ failed_when: "inventory_hostname == 'failed'"
+
+ - name: test magic vars exclude failed/unreachable hosts
+ assert:
+ that:
+ - ansible_play_batch | length == 1
+ - ansible_play_hosts | length == 1
+ - "ansible_play_batch == ['successful']"
+ - "ansible_play_hosts == ['successful']"
+ - ansible_play_hosts_all | length == 3
+ run_once: True
+
+- hosts: all
+ gather_facts: no
+ tasks:
+ - name: test failed/unreachable persists between plays
+ assert:
+ that:
+ - ansible_play_batch | length == 1
+ - ansible_play_hosts | length == 1
+ - "ansible_play_batch == ['successful']"
+ - "ansible_play_hosts == ['successful']"
+ - ansible_play_hosts_all | length == 3
+ run_once: True
diff --git a/test/integration/targets/special_vars_hosts/runme.sh b/test/integration/targets/special_vars_hosts/runme.sh
new file mode 100755
index 0000000000..81c1d9be65
--- /dev/null
+++ b/test/integration/targets/special_vars_hosts/runme.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook -i ./inventory playbook.yml "$@" | tee out.txt
+grep 'unreachable=2' out.txt
+grep 'failed=2' out.txt