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 --- .../roles/test_includes/tasks/branch_toplevel.yml | 11 ++ .../includes/roles/test_includes/tasks/empty.yml | 0 .../roles/test_includes/tasks/included_task1.yml | 9 ++ .../roles/test_includes/tasks/leaf_sublevel.yml | 2 + .../includes/roles/test_includes/tasks/main.yml | 114 +++++++++++++++++++++ .../roles/test_includes/tasks/not_a_role_task.yml | 4 + 6 files changed, 140 insertions(+) create mode 100644 test/integration/targets/includes/roles/test_includes/tasks/branch_toplevel.yml create mode 100644 test/integration/targets/includes/roles/test_includes/tasks/empty.yml create mode 100644 test/integration/targets/includes/roles/test_includes/tasks/included_task1.yml create mode 100644 test/integration/targets/includes/roles/test_includes/tasks/leaf_sublevel.yml create mode 100644 test/integration/targets/includes/roles/test_includes/tasks/main.yml create mode 100644 test/integration/targets/includes/roles/test_includes/tasks/not_a_role_task.yml (limited to 'test/integration/targets/includes/roles/test_includes/tasks') 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 0000000..30cd6f2 --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/tasks/branch_toplevel.yml @@ -0,0 +1,11 @@ +# 'canary2' used instead of 'canary', otherwise a "recursive loop detected in +# template string" occurs when both includes use static=yes +- import_tasks: leaf_sublevel.yml + vars: + canary2: '{{ canary }}' + when: 'nested_include_static|bool' # value for 'static' can not be a variable, hence use 'when' + +- include_tasks: leaf_sublevel.yml + vars: + canary2: '{{ canary }}' + 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 0000000..e69de29 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 0000000..6f4c048 --- /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 0000000..0663201 --- /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 0000000..83ca468 --- /dev/null +++ b/test/integration/targets/includes/roles/test_includes/tasks/main.yml @@ -0,0 +1,114 @@ +# test code for the ping module +# (c) 2014, James Cammarata + +# 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 . + + +- 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_tasks: branch_toplevel.yml + vars: + canary: value1 + nested_include_static: 'no' +- assert: + that: + - 'canary_fact == "value1"' + +- include_tasks: branch_toplevel.yml + vars: + canary: value2 + nested_include_static: 'yes' +- assert: + that: + - 'canary_fact == "value2"' + +- import_tasks: branch_toplevel.yml + vars: + canary: value3 + nested_include_static: 'no' +- assert: + that: + - 'canary_fact == "value3"' + +- import_tasks: branch_toplevel.yml + vars: + canary: value4 + nested_include_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 0000000..862b051 --- /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 -- cgit v1.2.3