summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/infra
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/infra')
-rw-r--r--test/integration/targets/infra/aliases4
-rw-r--r--test/integration/targets/infra/inventory.local2
-rw-r--r--test/integration/targets/infra/library/test.py24
-rwxr-xr-xtest/integration/targets/infra/runme.sh39
-rw-r--r--test/integration/targets/infra/test_test_infra.yml25
5 files changed, 94 insertions, 0 deletions
diff --git a/test/integration/targets/infra/aliases b/test/integration/targets/infra/aliases
new file mode 100644
index 0000000..af16cd4
--- /dev/null
+++ b/test/integration/targets/infra/aliases
@@ -0,0 +1,4 @@
+shippable/posix/group5
+needs/file/hacking/test-module.py
+needs/file/lib/ansible/modules/ping.py
+context/controller
diff --git a/test/integration/targets/infra/inventory.local b/test/integration/targets/infra/inventory.local
new file mode 100644
index 0000000..2baa1f8
--- /dev/null
+++ b/test/integration/targets/infra/inventory.local
@@ -0,0 +1,2 @@
+testhost ansible_connection=local
+
diff --git a/test/integration/targets/infra/library/test.py b/test/integration/targets/infra/library/test.py
new file mode 100644
index 0000000..dbc4b61
--- /dev/null
+++ b/test/integration/targets/infra/library/test.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec=dict(),
+ )
+ result = {
+ 'selinux_special_fs': module._selinux_special_fs,
+ 'tmpdir': module._tmpdir,
+ 'keep_remote_files': module._keep_remote_files,
+ 'version': module.ansible_version,
+ }
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/infra/runme.sh b/test/integration/targets/infra/runme.sh
new file mode 100755
index 0000000..9e348b8
--- /dev/null
+++ b/test/integration/targets/infra/runme.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+set -ux
+
+# ensure fail/assert work locally and can stop execution with non-zero exit code
+PB_OUT=$(ansible-playbook -i inventory.local test_test_infra.yml)
+APB_RC=$?
+echo "$PB_OUT"
+echo "rc was $APB_RC (must be non-zero)"
+[ ${APB_RC} -ne 0 ]
+echo "ensure playbook output shows assert/fail works (True)"
+echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
+echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
+
+# ensure we work using all specified test args, overridden inventory, etc
+PB_OUT=$(ansible-playbook -i ../../inventory test_test_infra.yml "$@")
+APB_RC=$?
+echo "$PB_OUT"
+echo "rc was $APB_RC (must be non-zero)"
+[ ${APB_RC} -ne 0 ]
+echo "ensure playbook output shows assert/fail works (True)"
+echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
+echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
+
+set -e
+
+PING_MODULE_PATH="../../../../lib/ansible/modules/ping.py"
+
+# ensure test-module.py script works without passing Python interpreter path
+../../../../hacking/test-module.py -m "$PING_MODULE_PATH"
+
+# ensure test-module.py script works well
+../../../../hacking/test-module.py -m "$PING_MODULE_PATH" -I ansible_python_interpreter="${ANSIBLE_TEST_PYTHON_INTERPRETER}"
+
+# ensure module.ansible_version is defined when using test-module.py
+../../../../hacking/test-module.py -m library/test.py -I ansible_python_interpreter="${ANSIBLE_TEST_PYTHON_INTERPRETER}" <<< '{"ANSIBLE_MODULE_ARGS": {}}'
+
+# ensure exercising module code locally works
+python -m ansible.modules.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}'
diff --git a/test/integration/targets/infra/test_test_infra.yml b/test/integration/targets/infra/test_test_infra.yml
new file mode 100644
index 0000000..706f9b8
--- /dev/null
+++ b/test/integration/targets/infra/test_test_infra.yml
@@ -0,0 +1,25 @@
+- hosts: testhost
+ gather_facts: no
+ tags:
+ - always
+ tasks:
+ - name: ensure fail action produces a failing result
+ fail:
+ ignore_errors: yes
+ register: fail_out
+
+ - debug:
+ msg: fail works ({{ fail_out.failed }})
+
+ - name: ensure assert produces a failing result
+ assert:
+ that: false
+ ignore_errors: yes
+ register: assert_out
+
+ - debug:
+ msg: assert works ({{ assert_out.failed }})
+
+ - name: EXPECTED FAILURE ensure fail action stops execution
+ fail:
+ msg: fail actually failed (this is expected)