summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/include_import/playbook
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/include_import/playbook')
-rw-r--r--test/integration/targets/include_import/playbook/group_vars/all.yml1
-rw-r--r--test/integration/targets/include_import/playbook/playbook1.yml9
-rw-r--r--test/integration/targets/include_import/playbook/playbook2.yml9
-rw-r--r--test/integration/targets/include_import/playbook/playbook3.yml10
-rw-r--r--test/integration/targets/include_import/playbook/playbook4.yml9
-rw-r--r--test/integration/targets/include_import/playbook/playbook_needing_vars.yml6
-rw-r--r--test/integration/targets/include_import/playbook/roles/import_playbook_role/tasks/main.yml2
-rw-r--r--test/integration/targets/include_import/playbook/sub_playbook/library/helloworld.py30
-rw-r--r--test/integration/targets/include_import/playbook/sub_playbook/sub_playbook.yml4
-rw-r--r--test/integration/targets/include_import/playbook/test_import_playbook.yml22
-rw-r--r--test/integration/targets/include_import/playbook/test_import_playbook_tags.yml10
-rw-r--r--test/integration/targets/include_import/playbook/test_templated_filenames.yml47
-rw-r--r--test/integration/targets/include_import/playbook/validate1.yml10
-rw-r--r--test/integration/targets/include_import/playbook/validate2.yml10
-rw-r--r--test/integration/targets/include_import/playbook/validate34.yml11
-rw-r--r--test/integration/targets/include_import/playbook/validate_tags.yml11
-rw-r--r--test/integration/targets/include_import/playbook/validate_templated_playbook.yml5
-rw-r--r--test/integration/targets/include_import/playbook/validate_templated_tasks.yml1
18 files changed, 207 insertions, 0 deletions
diff --git a/test/integration/targets/include_import/playbook/group_vars/all.yml b/test/integration/targets/include_import/playbook/group_vars/all.yml
new file mode 100644
index 0000000..9acd8c6
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/group_vars/all.yml
@@ -0,0 +1 @@
+group_var1: set in group_vars/all.yml
diff --git a/test/integration/targets/include_import/playbook/playbook1.yml b/test/integration/targets/include_import/playbook/playbook1.yml
new file mode 100644
index 0000000..55c66d8
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/playbook1.yml
@@ -0,0 +1,9 @@
+- name: Playbook 1
+ hosts: testhost2
+
+ tasks:
+ - name: Set fact in playbook 1
+ set_fact:
+ canary_var1: playbook1 imported
+ tags:
+ - canary1
diff --git a/test/integration/targets/include_import/playbook/playbook2.yml b/test/integration/targets/include_import/playbook/playbook2.yml
new file mode 100644
index 0000000..c986165
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/playbook2.yml
@@ -0,0 +1,9 @@
+- name: Playbook 2
+ hosts: testhost2
+
+ tasks:
+ - name: Set fact in playbook 2
+ set_fact:
+ canary_var2: playbook2 imported
+ tags:
+ - canary2
diff --git a/test/integration/targets/include_import/playbook/playbook3.yml b/test/integration/targets/include_import/playbook/playbook3.yml
new file mode 100644
index 0000000..b62b96c
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/playbook3.yml
@@ -0,0 +1,10 @@
+- name: Playbook 3
+ hosts: testhost2
+
+ tasks:
+ - name: Set fact in playbook 3
+ set_fact:
+ canary_var3: playbook3 imported
+ include_next_playbook: yes
+ tags:
+ - canary3
diff --git a/test/integration/targets/include_import/playbook/playbook4.yml b/test/integration/targets/include_import/playbook/playbook4.yml
new file mode 100644
index 0000000..330612a
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/playbook4.yml
@@ -0,0 +1,9 @@
+- name: Playbook 4
+ hosts: testhost2
+
+ tasks:
+ - name: Set fact in playbook 4
+ set_fact:
+ canary_var4: playbook4 imported
+ tags:
+ - canary4
diff --git a/test/integration/targets/include_import/playbook/playbook_needing_vars.yml b/test/integration/targets/include_import/playbook/playbook_needing_vars.yml
new file mode 100644
index 0000000..6454502
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/playbook_needing_vars.yml
@@ -0,0 +1,6 @@
+---
+- hosts: testhost
+ gather_facts: no
+ tasks:
+ - import_role:
+ name: "{{ import_playbook_role_name }}"
diff --git a/test/integration/targets/include_import/playbook/roles/import_playbook_role/tasks/main.yml b/test/integration/targets/include_import/playbook/roles/import_playbook_role/tasks/main.yml
new file mode 100644
index 0000000..7755439
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/roles/import_playbook_role/tasks/main.yml
@@ -0,0 +1,2 @@
+- debug:
+ msg: in import_playbook_role
diff --git a/test/integration/targets/include_import/playbook/sub_playbook/library/helloworld.py b/test/integration/targets/include_import/playbook/sub_playbook/library/helloworld.py
new file mode 100644
index 0000000..0ebe690
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/sub_playbook/library/helloworld.py
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+# 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/>.
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+def main():
+ module = AnsibleModule(argument_spec={})
+
+ module.exit_json(msg='Hello, World!')
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/include_import/playbook/sub_playbook/sub_playbook.yml b/test/integration/targets/include_import/playbook/sub_playbook/sub_playbook.yml
new file mode 100644
index 0000000..4399d93
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/sub_playbook/sub_playbook.yml
@@ -0,0 +1,4 @@
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - helloworld:
diff --git a/test/integration/targets/include_import/playbook/test_import_playbook.yml b/test/integration/targets/include_import/playbook/test_import_playbook.yml
new file mode 100644
index 0000000..4fcdb10
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/test_import_playbook.yml
@@ -0,0 +1,22 @@
+# Test and validate playbook import
+- import_playbook: playbook1.yml
+- import_playbook: validate1.yml
+
+# Test and validate conditional import
+- import_playbook: playbook2.yml
+ when: no
+
+- import_playbook: validate2.yml
+
+- import_playbook: playbook3.yml
+- import_playbook: playbook4.yml
+ when: include_next_playbook
+
+- import_playbook: validate34.yml
+
+- import_playbook: playbook_needing_vars.yml
+ vars:
+ import_playbook_role_name: import_playbook_role
+
+# https://github.com/ansible/ansible/issues/59548
+- import_playbook: sub_playbook/sub_playbook.yml
diff --git a/test/integration/targets/include_import/playbook/test_import_playbook_tags.yml b/test/integration/targets/include_import/playbook/test_import_playbook_tags.yml
new file mode 100644
index 0000000..46136f6
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/test_import_playbook_tags.yml
@@ -0,0 +1,10 @@
+- import_playbook: playbook1.yml # Test tag in tasks in included play
+- import_playbook: playbook2.yml # Test tag added to import_playbook
+ tags:
+ - canary22
+
+- import_playbook: playbook3.yml # Test skipping tags added to import_playbook
+ tags:
+ - skipme
+
+- import_playbook: validate_tags.yml # Validate
diff --git a/test/integration/targets/include_import/playbook/test_templated_filenames.yml b/test/integration/targets/include_import/playbook/test_templated_filenames.yml
new file mode 100644
index 0000000..2f78ab0
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/test_templated_filenames.yml
@@ -0,0 +1,47 @@
+- name: test templating import_playbook with extra vars
+ import_playbook: "{{ pb }}"
+
+- name: test templating import_playbook with vars
+ import_playbook: "{{ test_var }}"
+ vars:
+ test_var: validate_templated_playbook.yml
+
+- name: test templating import_tasks
+ hosts: localhost
+ gather_facts: no
+ vars:
+ play_var: validate_templated_tasks.yml
+ tasks:
+ - name: test templating import_tasks with play vars
+ import_tasks: "{{ play_var }}"
+
+ - name: test templating import_tasks with task vars
+ import_tasks: "{{ task_var }}"
+ vars:
+ task_var: validate_templated_tasks.yml
+
+ - name: test templating import_tasks with extra vars
+ import_tasks: "{{ tasks }}"
+
+- name: test templating import_role from_files
+ hosts: localhost
+ gather_facts: no
+ vars:
+ play_var: templated.yml
+ tasks:
+ - name: test templating import_role tasks_from with play vars
+ import_role:
+ name: role1
+ tasks_from: "{{ play_var }}"
+
+ - name: test templating import_role tasks_from with task vars
+ import_role:
+ name: role1
+ tasks_from: "{{ task_var }}"
+ vars:
+ task_var: templated.yml
+
+ - name: test templating import_role tasks_from with extra vars
+ import_role:
+ name: role1
+ tasks_from: "{{ tasks_from }}"
diff --git a/test/integration/targets/include_import/playbook/validate1.yml b/test/integration/targets/include_import/playbook/validate1.yml
new file mode 100644
index 0000000..0018344
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/validate1.yml
@@ -0,0 +1,10 @@
+- hosts: testhost2
+
+ tasks:
+ - name: Assert that variable was set in playbook1.yml
+ assert:
+ that:
+ - canary_var1 == 'playbook1 imported'
+ tags:
+ - validate
+ - validate1
diff --git a/test/integration/targets/include_import/playbook/validate2.yml b/test/integration/targets/include_import/playbook/validate2.yml
new file mode 100644
index 0000000..f22bcb6
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/validate2.yml
@@ -0,0 +1,10 @@
+- hosts: testhost2
+
+ tasks:
+ - name: Assert that playbook2.yml was skipeed
+ assert:
+ that:
+ - canary_var2 is not defined
+ tags:
+ - validate
+ - validate2
diff --git a/test/integration/targets/include_import/playbook/validate34.yml b/test/integration/targets/include_import/playbook/validate34.yml
new file mode 100644
index 0000000..fd53a30
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/validate34.yml
@@ -0,0 +1,11 @@
+- hosts: testhost2
+
+ tasks:
+ - name: Assert that playbook3.yml and playbook4.yml were imported
+ assert:
+ that:
+ - canary_var3 == 'playbook3 imported'
+ - canary_var4 == 'playbook4 imported'
+ tags:
+ - validate
+ - validate34
diff --git a/test/integration/targets/include_import/playbook/validate_tags.yml b/test/integration/targets/include_import/playbook/validate_tags.yml
new file mode 100644
index 0000000..acdcb1f
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/validate_tags.yml
@@ -0,0 +1,11 @@
+- hosts: testhost2
+
+ tasks:
+ - name: Assert that only tasks with tags were run
+ assert:
+ that:
+ - canary_var1 == 'playbook1 imported'
+ - canary_var2 == 'playbook2 imported'
+ - canary_var3 is not defined
+ tags:
+ - validate
diff --git a/test/integration/targets/include_import/playbook/validate_templated_playbook.yml b/test/integration/targets/include_import/playbook/validate_templated_playbook.yml
new file mode 100644
index 0000000..631ee9b
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/validate_templated_playbook.yml
@@ -0,0 +1,5 @@
+---
+- hosts: localhost
+ gather_facts: no
+ tasks:
+ - debug: msg="In imported playbook"
diff --git a/test/integration/targets/include_import/playbook/validate_templated_tasks.yml b/test/integration/targets/include_import/playbook/validate_templated_tasks.yml
new file mode 100644
index 0000000..16d682d
--- /dev/null
+++ b/test/integration/targets/include_import/playbook/validate_templated_tasks.yml
@@ -0,0 +1 @@
+- debug: msg="In imported tasks"