summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/ignore_unreachable
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/ignore_unreachable')
-rw-r--r--test/integration/targets/ignore_unreachable/aliases2
-rw-r--r--test/integration/targets/ignore_unreachable/fake_connectors/bad_exec.py14
-rw-r--r--test/integration/targets/ignore_unreachable/fake_connectors/bad_put_file.py14
-rw-r--r--test/integration/targets/ignore_unreachable/inventory3
-rw-r--r--test/integration/targets/ignore_unreachable/meta/main.yml2
-rwxr-xr-xtest/integration/targets/ignore_unreachable/runme.sh16
-rw-r--r--test/integration/targets/ignore_unreachable/test_base_cannot_connect.yml5
-rw-r--r--test/integration/targets/ignore_unreachable/test_cannot_connect.yml29
-rw-r--r--test/integration/targets/ignore_unreachable/test_with_bad_plugins.yml24
9 files changed, 109 insertions, 0 deletions
diff --git a/test/integration/targets/ignore_unreachable/aliases b/test/integration/targets/ignore_unreachable/aliases
new file mode 100644
index 0000000..1d28bdb
--- /dev/null
+++ b/test/integration/targets/ignore_unreachable/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group5
+context/controller
diff --git a/test/integration/targets/ignore_unreachable/fake_connectors/bad_exec.py b/test/integration/targets/ignore_unreachable/fake_connectors/bad_exec.py
new file mode 100644
index 0000000..0d8c385
--- /dev/null
+++ b/test/integration/targets/ignore_unreachable/fake_connectors/bad_exec.py
@@ -0,0 +1,14 @@
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import ansible.plugins.connection.local as ansible_local
+from ansible.errors import AnsibleConnectionFailure
+
+from ansible.utils.display import Display
+display = Display()
+
+
+class Connection(ansible_local.Connection):
+ def exec_command(self, cmd, in_data=None, sudoable=True):
+ display.debug('Intercepted call to exec remote command')
+ raise AnsibleConnectionFailure('BADLOCAL Error: this is supposed to fail')
diff --git a/test/integration/targets/ignore_unreachable/fake_connectors/bad_put_file.py b/test/integration/targets/ignore_unreachable/fake_connectors/bad_put_file.py
new file mode 100644
index 0000000..d4131f4
--- /dev/null
+++ b/test/integration/targets/ignore_unreachable/fake_connectors/bad_put_file.py
@@ -0,0 +1,14 @@
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import ansible.plugins.connection.local as ansible_local
+from ansible.errors import AnsibleConnectionFailure
+
+from ansible.utils.display import Display
+display = Display()
+
+
+class Connection(ansible_local.Connection):
+ def put_file(self, in_path, out_path):
+ display.debug('Intercepted call to send data')
+ raise AnsibleConnectionFailure('BADLOCAL Error: this is supposed to fail')
diff --git a/test/integration/targets/ignore_unreachable/inventory b/test/integration/targets/ignore_unreachable/inventory
new file mode 100644
index 0000000..495a68c
--- /dev/null
+++ b/test/integration/targets/ignore_unreachable/inventory
@@ -0,0 +1,3 @@
+nonexistent ansible_host=169.254.199.200
+bad_put_file ansible_host=localhost ansible_connection=bad_put_file
+bad_exec ansible_host=localhost ansible_connection=bad_exec
diff --git a/test/integration/targets/ignore_unreachable/meta/main.yml b/test/integration/targets/ignore_unreachable/meta/main.yml
new file mode 100644
index 0000000..07faa21
--- /dev/null
+++ b/test/integration/targets/ignore_unreachable/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_tests
diff --git a/test/integration/targets/ignore_unreachable/runme.sh b/test/integration/targets/ignore_unreachable/runme.sh
new file mode 100755
index 0000000..5b0ef19
--- /dev/null
+++ b/test/integration/targets/ignore_unreachable/runme.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+set -eux
+
+export ANSIBLE_CONNECTION_PLUGINS=./fake_connectors
+# use fake connectors that raise srrors at different stages
+ansible-playbook test_with_bad_plugins.yml -i inventory -v "$@"
+unset ANSIBLE_CONNECTION_PLUGINS
+
+ansible-playbook test_cannot_connect.yml -i inventory -v "$@"
+
+if ansible-playbook test_base_cannot_connect.yml -i inventory -v "$@"; then
+ echo "Playbook intended to fail succeeded. Connection succeeded to nonexistent host"
+ exit 99
+else
+ echo "Connection to nonexistent hosts failed without using ignore_unreachable. Success!"
+fi
diff --git a/test/integration/targets/ignore_unreachable/test_base_cannot_connect.yml b/test/integration/targets/ignore_unreachable/test_base_cannot_connect.yml
new file mode 100644
index 0000000..931c82b
--- /dev/null
+++ b/test/integration/targets/ignore_unreachable/test_base_cannot_connect.yml
@@ -0,0 +1,5 @@
+- hosts: [localhost, nonexistent]
+ gather_facts: false
+ tasks:
+ - name: Hi
+ ping:
diff --git a/test/integration/targets/ignore_unreachable/test_cannot_connect.yml b/test/integration/targets/ignore_unreachable/test_cannot_connect.yml
new file mode 100644
index 0000000..64e2bfe
--- /dev/null
+++ b/test/integration/targets/ignore_unreachable/test_cannot_connect.yml
@@ -0,0 +1,29 @@
+---
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - name: Hi
+ ping:
+- hosts: [localhost, nonexistent]
+ ignore_unreachable: true
+ gather_facts: false
+ tasks:
+ - name: Hi
+ ping:
+- hosts: nonexistent
+ ignore_unreachable: true
+ gather_facts: false
+ tasks:
+ - name: Hi
+ ping:
+ - name: This should print anyway
+ debug:
+ msg: This should print worked even though host was unreachable
+ - name: Hi
+ ping:
+ register: should_fail
+ - assert:
+ that:
+ - 'should_fail is unreachable'
+ - 'not (should_fail is skipped)'
+ - 'not (should_fail is failed)'
diff --git a/test/integration/targets/ignore_unreachable/test_with_bad_plugins.yml b/test/integration/targets/ignore_unreachable/test_with_bad_plugins.yml
new file mode 100644
index 0000000..5d62f19
--- /dev/null
+++ b/test/integration/targets/ignore_unreachable/test_with_bad_plugins.yml
@@ -0,0 +1,24 @@
+- hosts: bad_put_file
+ gather_facts: false
+ ignore_unreachable: true
+ tasks:
+ - name: Hi
+ ping:
+- hosts: bad_put_file
+ gather_facts: true
+ ignore_unreachable: true
+ tasks:
+ - name: Hi
+ ping:
+- hosts: bad_exec
+ gather_facts: false
+ ignore_unreachable: true
+ tasks:
+ - name: Hi
+ ping:
+- hosts: bad_exec
+ gather_facts: true
+ ignore_unreachable: true
+ tasks:
+ - name: Hi
+ ping: