summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/omit
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/omit')
-rw-r--r--test/integration/targets/omit/48673.yml4
-rw-r--r--test/integration/targets/omit/75692.yml31
-rw-r--r--test/integration/targets/omit/C75692.yml44
-rw-r--r--test/integration/targets/omit/aliases3
-rwxr-xr-xtest/integration/targets/omit/runme.sh11
5 files changed, 93 insertions, 0 deletions
diff --git a/test/integration/targets/omit/48673.yml b/test/integration/targets/omit/48673.yml
new file mode 100644
index 0000000..d25c8cf
--- /dev/null
+++ b/test/integration/targets/omit/48673.yml
@@ -0,0 +1,4 @@
+- hosts: testhost
+ serial: "{{ testing_omitted_variable | default(omit) }}"
+ tasks:
+ - debug:
diff --git a/test/integration/targets/omit/75692.yml b/test/integration/targets/omit/75692.yml
new file mode 100644
index 0000000..b4000c9
--- /dev/null
+++ b/test/integration/targets/omit/75692.yml
@@ -0,0 +1,31 @@
+- name: omit should reset to 'absent' or same context, not just 'default' value
+ hosts: testhost
+ gather_facts: false
+ become: yes
+ become_user: nobody
+ roles:
+ - name: setup_test_user
+ become: yes
+ become_user: root
+ tasks:
+ - shell: whoami
+ register: inherited
+
+ - shell: whoami
+ register: explicit_no
+ become: false
+
+ - shell: whoami
+ register: omited_inheritance
+ become: '{{ omit }}'
+
+ - shell: whoami
+ register: explicit_yes
+ become: yes
+
+ - name: ensure omit works with inheritance
+ assert:
+ that:
+ - inherited.stdout == omited_inheritance.stdout
+ - inherited.stdout == explicit_yes.stdout
+ - inherited.stdout != explicit_no.stdout
diff --git a/test/integration/targets/omit/C75692.yml b/test/integration/targets/omit/C75692.yml
new file mode 100644
index 0000000..6e1215f
--- /dev/null
+++ b/test/integration/targets/omit/C75692.yml
@@ -0,0 +1,44 @@
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - name: Make sure foo is gone
+ file:
+ path: foo
+ state: absent
+ - name: Create foo - should only be changed in first iteration
+ copy:
+ dest: foo
+ content: foo
+ check_mode: '{{ omit }}'
+ register: cmode
+ loop:
+ - 1
+ - 2
+
+ - when: ansible_check_mode
+ block:
+ - name: stat foo
+ stat: path=foo
+ register: foo
+ check_mode: off
+ - debug: var=foo
+ - name: validate expected outcomes when in check mode and file does not exist
+ assert:
+ that:
+ - cmode['results'][0] is changed
+ - cmode['results'][1] is changed
+ when: not foo['stat']['exists']
+
+ - name: validate expected outcomes when in check mode and file exists
+ assert:
+ that:
+ - cmode['results'][0] is not changed
+ - cmode['results'][1] is not changed
+ when: foo['stat']['exists']
+
+ - name: validate expected outcomes when not in check mode (file is always deleted)
+ assert:
+ that:
+ - cmode['results'][0] is changed
+ - cmode['results'][1] is not changed
+ when: not ansible_check_mode
diff --git a/test/integration/targets/omit/aliases b/test/integration/targets/omit/aliases
new file mode 100644
index 0000000..1bff31c
--- /dev/null
+++ b/test/integration/targets/omit/aliases
@@ -0,0 +1,3 @@
+shippable/posix/group5
+needs/target/setup_test_user
+context/controller
diff --git a/test/integration/targets/omit/runme.sh b/test/integration/targets/omit/runme.sh
new file mode 100755
index 0000000..e2f3c02
--- /dev/null
+++ b/test/integration/targets/omit/runme.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+set -eux
+
+# positive inheritance works
+ANSIBLE_ROLES_PATH=../ ansible-playbook 48673.yml 75692.yml -i ../../inventory -v "$@"
+
+# ensure negative also works
+ansible-playbook -C C75692.yml -i ../../inventory -v "$@" # expects 'foo' not to exist
+ansible-playbook C75692.yml -i ../../inventory -v "$@" # creates 'foo'
+ansible-playbook -C C75692.yml -i ../../inventory -v "$@" # expects 'foo' does exist