summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/includes/roles/test_includes/tasks/main.yml
blob: 83ca468baff178a23ab20adcd6e4b9b9adddfa91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# 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_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"'