File: corner_cases.yml

package info (click to toggle)
ansible-core 2.19.0~beta6-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 32,628 kB
  • sloc: python: 180,313; cs: 4,929; sh: 4,601; xml: 34; makefile: 21
file content (55 lines) | stat: -rw-r--r-- 1,774 bytes parent folder | download | duplicates (3)
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
- name: test tempating corner cases
  hosts: localhost
  gather_facts: false
  vars:
    empty_list: []
    dont: I SHOULD NOT BE TEMPLATED
    other: I WORK
  tasks:
    - name: 'ensure we are not interpolating data from outside of j2 delimiters'
      assert:
        that:
            - '"I SHOULD NOT BE TEMPLATED" not in adjacent'
            - globals1 == "[[], globals()]"
            - globals2 == "[[], globals]"
            - left_hand == '[1] + [2]'
            - left_hand_2 == '[1 + 2 * 3 / 4] + [-2.5, 2.5, 3.5]'
      vars:
        adjacent: "{{ empty_list }} + [dont]"
        globals1: "[{{ empty_list }}, globals()]"
        globals2: "[{{ empty_list }}, globals]"
        left_hand: '[1] + {{ [2] }}'
        left_hand_2: '[1 + 2 * 3 / 4] + {{ [-2.5, +2.5, 1 + 2.5] }}'

    - name: 'ensure we can add lists'
      assert:
        that:
            - (empty_list + [other]) == [other]
            - (empty_list + [other, other]) == [other, other]
            - (dont_exist|default([]) + [other]) == [other]
            - ([other] + [empty_list, other]) == [other, [], other]

    - name: 'ensure comments go away and we still dont interpolate in string'
      assert:
        that:
            - 'comm1 == " + [dont]"'
            - 'comm2 == " #} + [dont]"'
      vars:
        comm1: '{# {{nothing}} {# #} + [dont]'
        comm2: "{# {{nothing}} {# #} #} + [dont]"

    - name: test additions with facts, set them up
      set_fact:
        inames: []
        iname: "{{ prefix ~ '-options' }}"
        iname_1: "{{ prefix ~ '-options-1' }}"
      vars:
        prefix: 'bo'

    - name: add the facts
      set_fact:
        inames: '{{ inames + [iname, iname_1] }}'

    - assert:
        that:
            - inames == ['bo-options', 'bo-options-1']