From 8a754e0858d922e955e71b253c139e071ecec432 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 18:04:21 +0200 Subject: Adding upstream version 2.14.3. Signed-off-by: Daniel Baumann --- test/integration/targets/omit/48673.yml | 4 +++ test/integration/targets/omit/75692.yml | 31 ++++++++++++++++++++++ test/integration/targets/omit/C75692.yml | 44 ++++++++++++++++++++++++++++++++ test/integration/targets/omit/aliases | 3 +++ test/integration/targets/omit/runme.sh | 11 ++++++++ 5 files changed, 93 insertions(+) create mode 100644 test/integration/targets/omit/48673.yml create mode 100644 test/integration/targets/omit/75692.yml create mode 100644 test/integration/targets/omit/C75692.yml create mode 100644 test/integration/targets/omit/aliases create mode 100755 test/integration/targets/omit/runme.sh (limited to 'test/integration/targets/omit') 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 -- cgit v1.2.3