summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/playbook
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/playbook')
-rw-r--r--test/integration/targets/playbook/aliases2
-rw-r--r--test/integration/targets/playbook/empty.yml1
-rw-r--r--test/integration/targets/playbook/empty_hosts.yml4
-rw-r--r--test/integration/targets/playbook/malformed_post_tasks.yml2
-rw-r--r--test/integration/targets/playbook/malformed_pre_tasks.yml2
-rw-r--r--test/integration/targets/playbook/malformed_roles.yml2
-rw-r--r--test/integration/targets/playbook/malformed_tasks.yml2
-rw-r--r--test/integration/targets/playbook/malformed_vars_prompt.yml3
-rw-r--r--test/integration/targets/playbook/old_style_role.yml3
-rw-r--r--test/integration/targets/playbook/remote_user_and_user.yml6
-rw-r--r--test/integration/targets/playbook/roles_null.yml3
-rwxr-xr-xtest/integration/targets/playbook/runme.sh92
-rw-r--r--test/integration/targets/playbook/some_vars.yml2
-rw-r--r--test/integration/targets/playbook/timeout.yml12
-rw-r--r--test/integration/targets/playbook/types.yml21
-rw-r--r--test/integration/targets/playbook/user.yml23
-rw-r--r--test/integration/targets/playbook/vars_files_null.yml3
-rw-r--r--test/integration/targets/playbook/vars_files_string.yml6
-rw-r--r--test/integration/targets/playbook/vars_prompt_null.yml3
19 files changed, 192 insertions, 0 deletions
diff --git a/test/integration/targets/playbook/aliases b/test/integration/targets/playbook/aliases
new file mode 100644
index 0000000..8278ec8
--- /dev/null
+++ b/test/integration/targets/playbook/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group3
+context/controller
diff --git a/test/integration/targets/playbook/empty.yml b/test/integration/targets/playbook/empty.yml
new file mode 100644
index 0000000..fe51488
--- /dev/null
+++ b/test/integration/targets/playbook/empty.yml
@@ -0,0 +1 @@
+[]
diff --git a/test/integration/targets/playbook/empty_hosts.yml b/test/integration/targets/playbook/empty_hosts.yml
new file mode 100644
index 0000000..c9493c0
--- /dev/null
+++ b/test/integration/targets/playbook/empty_hosts.yml
@@ -0,0 +1,4 @@
+- hosts: []
+ tasks:
+ - debug:
+ msg: does not run
diff --git a/test/integration/targets/playbook/malformed_post_tasks.yml b/test/integration/targets/playbook/malformed_post_tasks.yml
new file mode 100644
index 0000000..4c13411
--- /dev/null
+++ b/test/integration/targets/playbook/malformed_post_tasks.yml
@@ -0,0 +1,2 @@
+- hosts: localhost
+ post_tasks: 123
diff --git a/test/integration/targets/playbook/malformed_pre_tasks.yml b/test/integration/targets/playbook/malformed_pre_tasks.yml
new file mode 100644
index 0000000..6c58477
--- /dev/null
+++ b/test/integration/targets/playbook/malformed_pre_tasks.yml
@@ -0,0 +1,2 @@
+- hosts: localhost
+ pre_tasks: 123
diff --git a/test/integration/targets/playbook/malformed_roles.yml b/test/integration/targets/playbook/malformed_roles.yml
new file mode 100644
index 0000000..35db56e
--- /dev/null
+++ b/test/integration/targets/playbook/malformed_roles.yml
@@ -0,0 +1,2 @@
+- hosts: localhost
+ roles: 123
diff --git a/test/integration/targets/playbook/malformed_tasks.yml b/test/integration/targets/playbook/malformed_tasks.yml
new file mode 100644
index 0000000..123c059
--- /dev/null
+++ b/test/integration/targets/playbook/malformed_tasks.yml
@@ -0,0 +1,2 @@
+- hosts: localhost
+ tasks: 123
diff --git a/test/integration/targets/playbook/malformed_vars_prompt.yml b/test/integration/targets/playbook/malformed_vars_prompt.yml
new file mode 100644
index 0000000..5447197
--- /dev/null
+++ b/test/integration/targets/playbook/malformed_vars_prompt.yml
@@ -0,0 +1,3 @@
+- hosts: localhost
+ vars_prompt:
+ - foo: bar
diff --git a/test/integration/targets/playbook/old_style_role.yml b/test/integration/targets/playbook/old_style_role.yml
new file mode 100644
index 0000000..015f263
--- /dev/null
+++ b/test/integration/targets/playbook/old_style_role.yml
@@ -0,0 +1,3 @@
+- hosts: localhost
+ roles:
+ - foo,bar
diff --git a/test/integration/targets/playbook/remote_user_and_user.yml b/test/integration/targets/playbook/remote_user_and_user.yml
new file mode 100644
index 0000000..c9e2389
--- /dev/null
+++ b/test/integration/targets/playbook/remote_user_and_user.yml
@@ -0,0 +1,6 @@
+- hosts: localhost
+ remote_user: a
+ user: b
+ tasks:
+ - debug:
+ msg: did not run
diff --git a/test/integration/targets/playbook/roles_null.yml b/test/integration/targets/playbook/roles_null.yml
new file mode 100644
index 0000000..d06bcd1
--- /dev/null
+++ b/test/integration/targets/playbook/roles_null.yml
@@ -0,0 +1,3 @@
+- name: null roles is okay
+ hosts: localhost
+ roles: null
diff --git a/test/integration/targets/playbook/runme.sh b/test/integration/targets/playbook/runme.sh
new file mode 100755
index 0000000..cc8d495
--- /dev/null
+++ b/test/integration/targets/playbook/runme.sh
@@ -0,0 +1,92 @@
+#!/usr/bin/env bash
+
+set -eux
+
+# run type tests
+ansible-playbook -i ../../inventory types.yml -v "$@"
+
+# test timeout
+ansible-playbook -i ../../inventory timeout.yml -v "$@"
+
+# our Play class allows for 'user' or 'remote_user', but not both.
+# first test that both user and remote_user work individually
+set +e
+result="$(ansible-playbook -i ../../inventory user.yml -v "$@" 2>&1)"
+set -e
+grep -q "worked with user" <<< "$result"
+grep -q "worked with remote_user" <<< "$result"
+
+# then test that the play errors if user and remote_user both exist
+echo "EXPECTED ERROR: Ensure we fail properly if a play has both user and remote_user."
+set +e
+result="$(ansible-playbook -i ../../inventory remote_user_and_user.yml -v "$@" 2>&1)"
+set -e
+grep -q "ERROR! both 'user' and 'remote_user' are set for this play." <<< "$result"
+
+# test that playbook errors if len(plays) == 0
+echo "EXPECTED ERROR: Ensure we fail properly if a playbook is an empty list."
+set +e
+result="$(ansible-playbook -i ../../inventory empty.yml -v "$@" 2>&1)"
+set -e
+grep -q "ERROR! A playbook must contain at least one play" <<< "$result"
+
+# test that play errors if len(hosts) == 0
+echo "EXPECTED ERROR: Ensure we fail properly if a play has 0 hosts."
+set +e
+result="$(ansible-playbook -i ../../inventory empty_hosts.yml -v "$@" 2>&1)"
+set -e
+grep -q "ERROR! Hosts list cannot be empty. Please check your playbook" <<< "$result"
+
+# test that play errors if tasks is malformed
+echo "EXPECTED ERROR: Ensure we fail properly if tasks is malformed."
+set +e
+result="$(ansible-playbook -i ../../inventory malformed_tasks.yml -v "$@" 2>&1)"
+set -e
+grep -q "ERROR! A malformed block was encountered while loading tasks: 123 should be a list or None" <<< "$result"
+
+# test that play errors if pre_tasks is malformed
+echo "EXPECTED ERROR: Ensure we fail properly if pre_tasks is malformed."
+set +e
+result="$(ansible-playbook -i ../../inventory malformed_pre_tasks.yml -v "$@" 2>&1)"
+set -e
+grep -q "ERROR! A malformed block was encountered while loading pre_tasks" <<< "$result"
+
+# test that play errors if post_tasks is malformed
+echo "EXPECTED ERROR: Ensure we fail properly if post_tasks is malformed."
+set +e
+result="$(ansible-playbook -i ../../inventory malformed_post_tasks.yml -v "$@" 2>&1)"
+set -e
+grep -q "ERROR! A malformed block was encountered while loading post_tasks" <<< "$result"
+
+# test roles: null -- it gets converted to [] internally
+ansible-playbook -i ../../inventory roles_null.yml -v "$@"
+
+# test roles: 123 -- errors
+echo "EXPECTED ERROR: Ensure we fail properly if roles is malformed."
+set +e
+result="$(ansible-playbook -i ../../inventory malformed_roles.yml -v "$@" 2>&1)"
+set -e
+grep -q "ERROR! A malformed role declaration was encountered." <<< "$result"
+
+# test roles: ["foo,bar"] -- errors about old style
+echo "EXPECTED ERROR: Ensure we fail properly if old style role is given."
+set +e
+result="$(ansible-playbook -i ../../inventory old_style_role.yml -v "$@" 2>&1)"
+set -e
+grep -q "ERROR! Invalid old style role requirement: foo,bar" <<< "$result"
+
+# test vars prompt that has no name
+echo "EXPECTED ERROR: Ensure we fail properly if vars_prompt has no name."
+set +e
+result="$(ansible-playbook -i ../../inventory malformed_vars_prompt.yml -v "$@" 2>&1)"
+set -e
+grep -q "ERROR! Invalid vars_prompt data structure, missing 'name' key" <<< "$result"
+
+# test vars_prompt: null
+ansible-playbook -i ../../inventory vars_prompt_null.yml -v "$@"
+
+# test vars_files: null
+ansible-playbook -i ../../inventory vars_files_null.yml -v "$@"
+
+# test vars_files: filename.yml
+ansible-playbook -i ../../inventory vars_files_string.yml -v "$@"
diff --git a/test/integration/targets/playbook/some_vars.yml b/test/integration/targets/playbook/some_vars.yml
new file mode 100644
index 0000000..7835365
--- /dev/null
+++ b/test/integration/targets/playbook/some_vars.yml
@@ -0,0 +1,2 @@
+a_variable: yep
+another: hi
diff --git a/test/integration/targets/playbook/timeout.yml b/test/integration/targets/playbook/timeout.yml
new file mode 100644
index 0000000..442e13a
--- /dev/null
+++ b/test/integration/targets/playbook/timeout.yml
@@ -0,0 +1,12 @@
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - shell: sleep 100
+ timeout: 1
+ ignore_errors: true
+ register: time
+
+ - assert:
+ that:
+ - time is failed
+ - '"The shell action failed to execute in the expected time frame" in time["msg"]'
diff --git a/test/integration/targets/playbook/types.yml b/test/integration/targets/playbook/types.yml
new file mode 100644
index 0000000..dd8997b
--- /dev/null
+++ b/test/integration/targets/playbook/types.yml
@@ -0,0 +1,21 @@
+- hosts: testhost
+ gather_facts: false
+ tasks:
+ - name: try to set 'diff' a boolean
+ debug: msg="not important"
+ diff: yes
+ ignore_errors: True
+ register: good_diff
+
+ - name: try to set 'diff' a boolean to a string (. would make it non boolean)
+ debug: msg="not important"
+ diff: yes.
+ ignore_errors: True
+ register: bad_diff
+
+ - name: Check we did error out
+ assert:
+ that:
+ - good_diff is success
+ - bad_diff is failed
+ - "'is not a valid boolean' in bad_diff['msg']"
diff --git a/test/integration/targets/playbook/user.yml b/test/integration/targets/playbook/user.yml
new file mode 100644
index 0000000..8b4029b
--- /dev/null
+++ b/test/integration/targets/playbook/user.yml
@@ -0,0 +1,23 @@
+- hosts: localhost
+ tasks:
+ - command: whoami
+ register: whoami
+
+ - assert:
+ that:
+ - whoami is successful
+
+ - set_fact:
+ me: "{{ whoami.stdout }}"
+
+- hosts: localhost
+ user: "{{ me }}"
+ tasks:
+ - debug:
+ msg: worked with user ({{ me }})
+
+- hosts: localhost
+ remote_user: "{{ me }}"
+ tasks:
+ - debug:
+ msg: worked with remote_user ({{ me }})
diff --git a/test/integration/targets/playbook/vars_files_null.yml b/test/integration/targets/playbook/vars_files_null.yml
new file mode 100644
index 0000000..64c21c6
--- /dev/null
+++ b/test/integration/targets/playbook/vars_files_null.yml
@@ -0,0 +1,3 @@
+- name: null vars_files is okay
+ hosts: localhost
+ vars_files: null
diff --git a/test/integration/targets/playbook/vars_files_string.yml b/test/integration/targets/playbook/vars_files_string.yml
new file mode 100644
index 0000000..9191d3c
--- /dev/null
+++ b/test/integration/targets/playbook/vars_files_string.yml
@@ -0,0 +1,6 @@
+- hosts: localhost
+ vars_files: some_vars.yml
+ tasks:
+ - assert:
+ that:
+ - 'a_variable == "yep"'
diff --git a/test/integration/targets/playbook/vars_prompt_null.yml b/test/integration/targets/playbook/vars_prompt_null.yml
new file mode 100644
index 0000000..4fdfa7c
--- /dev/null
+++ b/test/integration/targets/playbook/vars_prompt_null.yml
@@ -0,0 +1,3 @@
+- name: null vars prompt is okay
+ hosts: localhost
+ vars_prompt: null