Debian Codegraph @

test/integration/targets/template/corner_cases.yml

raw
1 - name: test templating corner cases
2 hosts: localhost
3 gather_facts: false
4 vars:
5 empty_list: []
6 dont: I SHOULD NOT BE TEMPLATED
7 other: I WORK
8 tasks:
9 - name: 'ensure we are not interpolating data from outside of j2 delimiters'
10 assert:
11 that:
12 - '"I SHOULD NOT BE TEMPLATED" not in adjacent'
13 - globals1 == "[[], globals()]"
14 - globals2 == "[[], globals]"
15 - left_hand == '[1] + [2]'
16 - left_hand_2 == '[1 + 2 * 3 / 4] + [-2.5, 2.5, 3.5]'
17 vars:
18 adjacent: "{{ empty_list }} + [dont]"
19 globals1: "[{{ empty_list }}, globals()]"
20 globals2: "[{{ empty_list }}, globals]"
21 left_hand: '[1] + {{ [2] }}'
22 left_hand_2: '[1 + 2 * 3 / 4] + {{ [-2.5, +2.5, 1 + 2.5] }}'
23
24 - name: 'ensure we can add lists'
25 assert:
26 that:
27 - (empty_list + [other]) == [other]
28 - (empty_list + [other, other]) == [other, other]
29 - (dont_exist|default([]) + [other]) == [other]
30 - ([other] + [empty_list, other]) == [other, [], other]
31
32 - name: 'ensure comments go away and we still dont interpolate in string'
33 assert:
34 that:
35 - 'comm1 == " + [dont]"'
36 - 'comm2 == " #} + [dont]"'
37 vars:
38 comm1: '{# {{nothing}} {# #} + [dont]'
39 comm2: "{# {{nothing}} {# #} #} + [dont]"
40
41 - name: test additions with facts, set them up
42 set_fact:
43 inames: []
44 iname: "{{ prefix ~ '-options' }}"
45 iname_1: "{{ prefix ~ '-options-1' }}"
46 vars:
47 prefix: 'bo'
48
49 - name: add the facts
50 set_fact:
51 inames: '{{ inames + [iname, iname_1] }}'
52
53 - assert:
54 that:
55 - inames == ['bo-options', 'bo-options-1']