Debian Codegraph @

test/integration/targets/template/unsafe.yml

raw
1 - hosts: localhost
2 gather_facts: false
3 vars:
4 nottemplated: this should not be seen
5 imunsafe: !unsafe '{{ nottemplated }}'
6 unsafe_set: !unsafe '{{ "test" }}'
7 tasks:
8
9 - set_fact:
10 this_was_unsafe: >
11 {{ imunsafe }}
12
13 - set_fact:
14 this_always_safe: '{{ imunsafe }}'
15
16 - set_fact:
17 this_unsafe_set: "{{ unsafe_set }}"
18
19 - name: ensure nothing was templated
20 assert:
21 that:
22 - this_always_safe == imunsafe
23 - imunsafe == this_was_unsafe.strip()
24 - unsafe_set == this_unsafe_set.strip()
25
26
27 - hosts: localhost
28 gather_facts: false
29 vars:
30 output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
31 tasks:
32 - set_fact:
33 unsafe_foo: "{{ lookup('list', var0) }}"
34 vars:
35 var0: "{{ var1 }}"
36 var1:
37 - unsafe
38
39 - assert:
40 that:
41 - unsafe_foo is not ansible._protomatter.tagged_with('TrustedAsTemplate')
42
43 - block:
44 - copy:
45 dest: "{{ file_name }}"
46 content: !unsafe "{{ i_should_not_be_templated }}"
47
48 - set_fact:
49 file_content: "{{ lookup('file', file_name) }}"
50
51 - assert:
52 that:
53 - not file_content is contains('unsafe')
54
55 - set_fact:
56 file_content: "{{ lookup('file', file_name_tmpl) }}"
57 vars:
58 file_name_tmpl: "{{ file_name }}"
59
60 - assert:
61 that:
62 - not file_content is contains('unsafe')
63 vars:
64 file_name: "{{ output_dir }}/unsafe_file"
65 i_should_not_be_templated: unsafe
66 always:
67 - file:
68 dest: "{{ file_name }}"
69 state: absent