diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
commit | a453ac31f3428614cceb99027f8efbdb9258a40b (patch) | |
tree | f61f87408f32a8511cbd91799f9cececb53e0374 /test/integration/targets/includes | |
parent | Initial commit. (diff) | |
download | ansible-upstream.tar.xz ansible-upstream.zip |
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
28 files changed, 298 insertions, 0 deletions
diff --git a/test/integration/targets/includes/aliases b/test/integration/targets/includes/aliases new file mode 100644 index 00000000..b5983214 --- /dev/null +++ b/test/integration/targets/includes/aliases @@ -0,0 +1 @@ +shippable/posix/group3 diff --git a/test/integration/targets/includes/roles/test_includes/handlers/main.yml b/test/integration/targets/includes/roles/test_includes/handlers/main.yml new file mode 100644 index 00000000..7d3e625f --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/handlers/main.yml @@ -0,0 +1 @@ +- include: more_handlers.yml diff --git a/test/integration/targets/includes/roles/test_includes/handlers/more_handlers.yml b/test/integration/targets/includes/roles/test_includes/handlers/more_handlers.yml new file mode 100644 index 00000000..c85d53cc --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/handlers/more_handlers.yml @@ -0,0 +1,12 @@ +- name: included_handler + set_fact: + ca: 4001 + cb: 4002 + cc: 4003 + +- name: verify_handler + assert: + that: + - "ca == 4001" + - "cb == 4002" + - "cc == 4003" diff --git a/test/integration/targets/includes/roles/test_includes/tasks/branch_toplevel.yml b/test/integration/targets/includes/roles/test_includes/tasks/branch_toplevel.yml new file mode 100644 index 00000000..62416705 --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/tasks/branch_toplevel.yml @@ -0,0 +1,9 @@ +# 'canary2' used instead of 'canary', otherwise a "recursive loop detected in +# template string" occurs when both includes use static=yes +- include: 'leaf_sublevel.yml canary2={{ canary }}' + static: yes + when: 'nested_include_static|bool' # value for 'static' can not be a variable, hence use 'when' + +- include: 'leaf_sublevel.yml canary2={{ canary }}' + static: no + when: 'not nested_include_static|bool' diff --git a/test/integration/targets/includes/roles/test_includes/tasks/empty.yml b/test/integration/targets/includes/roles/test_includes/tasks/empty.yml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/tasks/empty.yml diff --git a/test/integration/targets/includes/roles/test_includes/tasks/included_task1.yml b/test/integration/targets/includes/roles/test_includes/tasks/included_task1.yml new file mode 100644 index 00000000..6f4c0480 --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/tasks/included_task1.yml @@ -0,0 +1,9 @@ +- set_fact: + ca: "{{ a }}" +- debug: var=ca +- set_fact: + cb: "{{b}}" +- debug: var=cb +- set_fact: + cc: "{{ c }}" +- debug: var=cc diff --git a/test/integration/targets/includes/roles/test_includes/tasks/leaf_sublevel.yml b/test/integration/targets/includes/roles/test_includes/tasks/leaf_sublevel.yml new file mode 100644 index 00000000..06632017 --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/tasks/leaf_sublevel.yml @@ -0,0 +1,2 @@ +- set_fact: + canary_fact: '{{ canary2 }}' diff --git a/test/integration/targets/includes/roles/test_includes/tasks/main.yml b/test/integration/targets/includes/roles/test_includes/tasks/main.yml new file mode 100644 index 00000000..6fcac9eb --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/tasks/main.yml @@ -0,0 +1,106 @@ +# test code for the ping module +# (c) 2014, James Cammarata <jcammarata@ansible.com> + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + + +- include: included_task1.yml a=1 b=2 c=3 + +- name: verify non-variable include params + assert: + that: + - "ca == '1'" + - "cb == '2'" + - "cc == '3'" + +- set_fact: + a: 101 + b: 102 + c: 103 + +- include: included_task1.yml a={{a}} b={{b}} c=103 + +- name: verify variable include params + assert: + that: + - "ca == 101" + - "cb == 102" + - "cc == 103" + +# Test that strings are not turned into numbers +- set_fact: + a: "101" + b: "102" + c: "103" + +- include: included_task1.yml a={{a}} b={{b}} c=103 + +- name: verify variable include params + assert: + that: + - "ca == '101'" + - "cb == '102'" + - "cc == '103'" + +# now try long form includes + +- include: included_task1.yml + vars: + a: 201 + b: 202 + c: 203 + +- debug: var=a +- debug: var=b +- debug: var=c + +- name: verify long-form include params + assert: + that: + - "ca == 201" + - "cb == 202" + - "cc == 203" + +- name: test handlers with includes + shell: echo 1 + notify: + # both these via a handler include + - included_handler + - verify_handler + +- include: branch_toplevel.yml canary=value1 nested_include_static=no + static: no +- assert: + that: + - 'canary_fact == "value1"' + +- include: branch_toplevel.yml canary=value2 nested_include_static=yes + static: no +- assert: + that: + - 'canary_fact == "value2"' + +- include: branch_toplevel.yml canary=value3 nested_include_static=no + static: yes +- assert: + that: + - 'canary_fact == "value3"' + +- include: branch_toplevel.yml canary=value4 nested_include_static=yes + static: yes +- assert: + that: + - 'canary_fact == "value4"' diff --git a/test/integration/targets/includes/roles/test_includes/tasks/not_a_role_task.yml b/test/integration/targets/includes/roles/test_includes/tasks/not_a_role_task.yml new file mode 100644 index 00000000..862b051c --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/tasks/not_a_role_task.yml @@ -0,0 +1,4 @@ +- set_fact: + ca: 33000 + cb: 33001 + cc: 33002 diff --git a/test/integration/targets/includes/roles/test_includes_free/tasks/inner.yml b/test/integration/targets/includes/roles/test_includes_free/tasks/inner.yml new file mode 100644 index 00000000..d9c32f4f --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes_free/tasks/inner.yml @@ -0,0 +1,2 @@ +- set_fact: + inner: "reached" diff --git a/test/integration/targets/includes/roles/test_includes_free/tasks/inner_fqcn.yml b/test/integration/targets/includes/roles/test_includes_free/tasks/inner_fqcn.yml new file mode 100644 index 00000000..5b4ce040 --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes_free/tasks/inner_fqcn.yml @@ -0,0 +1,2 @@ +- set_fact: + inner_fqcn: "reached" diff --git a/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml b/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml new file mode 100644 index 00000000..5ae7882f --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml @@ -0,0 +1,9 @@ +- name: this needs to be here + debug: + msg: "hello" +- include: inner.yml + with_items: + - '1' +- ansible.builtin.include: inner_fqcn.yml + with_items: + - '1' diff --git a/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/inner.yml b/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/inner.yml new file mode 100644 index 00000000..fa4ec93e --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/inner.yml @@ -0,0 +1,2 @@ +- set_fact: + inner_host_pinned: "reached" diff --git a/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/main.yml b/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/main.yml new file mode 100644 index 00000000..7bc19faa --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/main.yml @@ -0,0 +1,6 @@ +- name: this needs to be here + debug: + msg: "hello" +- include: inner.yml + with_items: + - '1' diff --git a/test/integration/targets/includes/runme.sh b/test/integration/targets/includes/runme.sh new file mode 100755 index 00000000..dff40029 --- /dev/null +++ b/test/integration/targets/includes/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook test_includes.yml -i ../../inventory "$@" diff --git a/test/integration/targets/includes/test_include_free.yml b/test/integration/targets/includes/test_include_free.yml new file mode 100644 index 00000000..dedad734 --- /dev/null +++ b/test/integration/targets/includes/test_include_free.yml @@ -0,0 +1,10 @@ +- hosts: testhost + gather_facts: no + strategy: free + roles: + - test_includes_free + tasks: + - assert: + that: + - "inner == 'reached'" + - "inner_fqcn == 'reached'" diff --git a/test/integration/targets/includes/test_include_host_pinned.yml b/test/integration/targets/includes/test_include_host_pinned.yml new file mode 100644 index 00000000..6ff92c66 --- /dev/null +++ b/test/integration/targets/includes/test_include_host_pinned.yml @@ -0,0 +1,9 @@ +- hosts: testhost + gather_facts: no + strategy: host_pinned + roles: + - test_includes_host_pinned + tasks: + - assert: + that: + - "inner_host_pinned == 'reached'" diff --git a/test/integration/targets/includes/test_includes.yml b/test/integration/targets/includes/test_includes.yml new file mode 100644 index 00000000..0bcebd4f --- /dev/null +++ b/test/integration/targets/includes/test_includes.yml @@ -0,0 +1,7 @@ +- include: test_includes2.yml parameter1=asdf parameter2=jkl + +- include: test_includes3.yml + +- include: test_include_free.yml + +- include: test_include_host_pinned.yml diff --git a/test/integration/targets/includes/test_includes2.yml b/test/integration/targets/includes/test_includes2.yml new file mode 100644 index 00000000..a32e8513 --- /dev/null +++ b/test/integration/targets/includes/test_includes2.yml @@ -0,0 +1,22 @@ +- name: verify playbook includes can take parameters + hosts: testhost + tasks: + - assert: + that: + - "parameter1 == 'asdf'" + - "parameter2 == 'jkl'" + +- name: verify task include logic + hosts: testhost + gather_facts: True + roles: + - role: test_includes + tags: test_includes + tasks: + - include: roles/test_includes/tasks/not_a_role_task.yml + - include: roles/test_includes/tasks/empty.yml + - assert: + that: + - "ca == 33000" + - "cb == 33001" + - "cc == 33002" diff --git a/test/integration/targets/includes/test_includes3.yml b/test/integration/targets/includes/test_includes3.yml new file mode 100644 index 00000000..0b4c6312 --- /dev/null +++ b/test/integration/targets/includes/test_includes3.yml @@ -0,0 +1,6 @@ +- hosts: testhost + tasks: + - include: test_includes4.yml + with_items: ["a"] + loop_control: + loop_var: r diff --git a/test/integration/targets/includes/test_includes4.yml b/test/integration/targets/includes/test_includes4.yml new file mode 100644 index 00000000..bee906bd --- /dev/null +++ b/test/integration/targets/includes/test_includes4.yml @@ -0,0 +1,2 @@ +- set_fact: + p: 1 diff --git a/test/integration/targets/includes_race/aliases b/test/integration/targets/includes_race/aliases new file mode 100644 index 00000000..fff62d9f --- /dev/null +++ b/test/integration/targets/includes_race/aliases @@ -0,0 +1,2 @@ +shippable/posix/group5 +skip/aix diff --git a/test/integration/targets/includes_race/inventory b/test/integration/targets/includes_race/inventory new file mode 100644 index 00000000..87879294 --- /dev/null +++ b/test/integration/targets/includes_race/inventory @@ -0,0 +1,30 @@ +host001 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host002 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host003 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host004 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host005 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host006 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host007 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host008 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host009 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host010 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host011 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host012 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host013 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host014 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host015 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host016 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host017 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host018 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host019 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host020 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host021 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host022 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host023 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host024 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host025 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host026 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host027 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host028 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host029 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" +host030 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}" diff --git a/test/integration/targets/includes_race/roles/random_sleep/tasks/main.yml b/test/integration/targets/includes_race/roles/random_sleep/tasks/main.yml new file mode 100644 index 00000000..cee459a2 --- /dev/null +++ b/test/integration/targets/includes_race/roles/random_sleep/tasks/main.yml @@ -0,0 +1,8 @@ +--- +# tasks file for random_sleep +- name: Generate sleep time + set_fact: + sleep_time: "{{ 3 | random }}" + +- name: Do random sleep + shell: sleep "{{ sleep_time }}" diff --git a/test/integration/targets/includes_race/roles/set_a_fact/tasks/fact1.yml b/test/integration/targets/includes_race/roles/set_a_fact/tasks/fact1.yml new file mode 100644 index 00000000..36b08dcb --- /dev/null +++ b/test/integration/targets/includes_race/roles/set_a_fact/tasks/fact1.yml @@ -0,0 +1,4 @@ +--- +- name: Set fact1 + set_fact: + fact1: yay diff --git a/test/integration/targets/includes_race/roles/set_a_fact/tasks/fact2.yml b/test/integration/targets/includes_race/roles/set_a_fact/tasks/fact2.yml new file mode 100644 index 00000000..865f130d --- /dev/null +++ b/test/integration/targets/includes_race/roles/set_a_fact/tasks/fact2.yml @@ -0,0 +1,4 @@ +--- +- name: Set fact2 + set_fact: + fact2: yay diff --git a/test/integration/targets/includes_race/runme.sh b/test/integration/targets/includes_race/runme.sh new file mode 100755 index 00000000..2261d271 --- /dev/null +++ b/test/integration/targets/includes_race/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook test_includes_race.yml -i inventory -v "$@" diff --git a/test/integration/targets/includes_race/test_includes_race.yml b/test/integration/targets/includes_race/test_includes_race.yml new file mode 100644 index 00000000..20f7dddd --- /dev/null +++ b/test/integration/targets/includes_race/test_includes_race.yml @@ -0,0 +1,19 @@ +- hosts: all + strategy: free + gather_facts: false + tasks: + - include_role: + name: random_sleep + - block: + - name: set a fact (1) + include_role: + name: set_a_fact + tasks_from: fact1.yml + - name: set a fact (2) + include_role: + name: set_a_fact + tasks_from: fact2.yml + - name: include didn't run + fail: + msg: "set_a_fact didn't run fact1 {{ fact1 | default('not defined')}} fact2: {{ fact2 | default('not defined') }}" + when: (fact1 is not defined or fact2 is not defined) |