Debian Codegraph @

test/integration/targets/templating_lookups/template_lookups/tasks/main.yml

raw
1 # UNICODE
2
3 # https://github.com/ansible/ansible/issues/65297
4 - name: get UNICODE_VAR environment var value
5 shell: "echo $UNICODE_VAR"
6 register: unicode_var_value
7
8 - name: verify the UNICODE_VAR is defined
9 assert:
10 that:
11 - "unicode_var_value.stdout is truthy"
12
13 - name: use env lookup to get UNICODE_VAR value
14 set_fact:
15 test_unicode_val: "{{ lookup('env', 'UNICODE_VAR') }}"
16
17 - debug: var=unicode_var_value
18 - debug: var=test_unicode_val
19
20 - name: compare unicode values
21 assert:
22 that:
23 - "test_unicode_val == unicode_var_value.stdout"
24
25 # LOOKUP TEMPLATING
26
27 - name: use bare interpolation
28 debug: msg="got {{item}}"
29 with_items: "{{things1}}"
30 register: bare_var
31
32 - name: verify that list was interpolated
33 assert:
34 that:
35 - "bare_var.results[0].item == 1"
36 - "bare_var.results[1].item == 2"
37
38 - name: use list with bare strings in it
39 debug: msg={{item}}
40 with_items:
41 - things2
42 - things1
43
44 - name: use list with undefined var in it
45 debug: msg={{item}}
46 with_items: "{{things2}}"
47 ignore_errors: True
48
49 # BUG #10073 nested template handling
50
51 - name: set variable that clashes
52 set_fact:
53 PATH: foobar
54
55 - name: get PATH environment var value
56 set_fact:
57 known_var_value: "{{ lookup('pipe', 'echo $PATH') }}"
58
59 - name: do the lookup for env PATH
60 set_fact:
61 test_val: "{{ lookup('env', 'PATH') }}"
62
63 - debug: var=test_val
64
65 - name: compare values
66 assert:
67 that:
68 - "test_val != ''"
69 - "test_val == known_var_value"
70
71 - name: set with_dict
72 shell: echo "{{ item.key + '=' + item.value }}"
73 with_dict: "{{ mydict }}"
74
75 # BUG #34144 bad template caching
76
77 - name: generate two random passwords
78 set_fact:
79 password1: "{{ lookup('password', '/dev/null length=20') }}"
80 password2: "{{ lookup('password', '/dev/null length=20') }}"
81 # If the passwords are generated randomly, the chance that they
82 # coincide is neglectable (< 1e-18 assuming 120 bits of randomness
83 # per password).
84
85 - name: make sure passwords are not the same
86 assert:
87 that:
88 - password1 != password2
89
90 - include_tasks: ./errors.yml