Debian Codegraph @

test/integration/targets/lookup_config/tasks/main.yml

raw symbols SCIP
1 - name: Verify lookup_config errors with no on_missing (failure expected)
2 set_fact:
3 foo: '{{lookup("config", "THIS_DOES_NOT_EXIST")}}'
4 ignore_errors: yes
5 register: lookup_config_1
6
7 - name: Verify lookup_config errors with on_missing=error (failure expected)
8 set_fact:
9 foo: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="error")}}'
10 ignore_errors: yes
11 register: lookup_config_2
12
13 - name: Verify lookup_config does not error with on_missing=skip
14 set_fact:
15 lookup3: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="skip")}}'
16 register: lookup_config_3
17
18 # TODO: Is there a decent way to check that the warning is actually triggered?
19 - name: Verify lookup_config does not error with on_missing=warn (warning expected)
20 set_fact:
21 lookup4: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="warn")}}'
22 register: lookup_config_4
23
24 - name: Verify lookup_config errors with invalid on_missing (failure expected)
25 set_fact:
26 foo: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="boo")}}'
27 ignore_errors: yes
28 register: lookup_config_5
29
30 - name: Verify lookup_config errors with invalid param type (failure expected)
31 set_fact:
32 foo: '{{lookup("config", 1337)}}'
33 ignore_errors: yes
34 register: lookup_config_6
35
36 - name: Verify lookup_config errors with callable arg (failure expected)
37 set_fact:
38 foo: '{{lookup("config", "ConfigManager")}}'
39 ignore_errors: yes
40 register: lookup_config_7
41
42 - name: remote user and port for ssh connection
43 set_fact:
44 ssh_user_and_port: '{{q("config", "remote_user", "port", plugin_type="connection", plugin_name="ssh")}}'
45 ssh_user_and_port_and_origin: '{{q("config", "remote_user", "port", plugin_type="connection", plugin_name="ssh", show_origin=True)}}'
46 vars:
47 ansible_ssh_user: lola
48 ansible_ssh_port: 2022
49
50 - name: remote_tmp for sh shell plugin
51 set_fact:
52 yolo_remote: '{{q("config", "remote_tmp", plugin_type="shell", plugin_name="sh")}}'
53 vars:
54 ansible_remote_tmp: yolo
55
56 - name: check if plugin_type and plugin_name is required together
57 set_fact:
58 lookup_failure: '{{ q("config", "remote_tmp", plugin_type="shell") }}'
59 ignore_errors: yes
60 register: lookup_config_8
61
62 - name: check if plugin_type and plugin_name is required together
63 set_fact:
64 lookup_failure: '{{ q("config", "remote_tmp", plugin_name="sh") }}'
65 ignore_errors: yes
66 register: lookup_config_9
67
68 - name: query non-existent config setting
69 set_fact:
70 lookup_failure: "{{ q('config', 'plugin_type1', plugin_type='lookup', plugin_name='config', ) }}"
71 ignore_errors: yes
72 register: lookup_config_10
73
74 - name: query non-existent plugin
75 set_fact:
76 lookup_failure: "{{ q('config', 'plugin_type', plugin_type='lookup', plugin_name='some.nonexistent.mylookup', ) }}"
77 ignore_errors: yes
78 register: lookup_config_11
79
80 - name: exception handling while reading configuration
81 set_fact:
82 lookup_failure: "{{ q('config', 'test_list', plugin_type='lookup', plugin_name='bogus', ) }}"
83 ignore_errors: yes
84 register: lookup_config_12
85
86 - name: origins
87 set_fact:
88 config_origin1: "{{ lookup('config', '_Z_TEST_ENTRY', show_origin=True) }}"
89 ignore_errors: yes
90
91 - name: var sets it
92 set_fact:
93 config_origin2: "{{ lookup('config', '_Z_TEST_ENTRY', show_origin=True) }}"
94 ignore_errors: yes
95 vars:
96 _z_test_entry: yolo
97
98 - name: Verify lookup_config
99 assert:
100 that:
101 - '"meow" in lookup("config", "ANSIBLE_COW_ACCEPTLIST")'
102 - lookup_config_1 is failed
103 - lookup_config_1.msg is contains "No config definition exists for 'THIS_DOES_NOT_EXIST'"
104 - lookup_config_2 is failed
105 - lookup_config_2.msg is contains "No config definition exists for 'THIS_DOES_NOT_EXIST'"
106 - lookup_config_3 is success
107 - 'lookup3|length == 0'
108 - lookup_config_4 is success
109 - 'lookup4|length == 0'
110 - lookup_config_5 is failed
111 - lookup_config_5.msg is contains "Invalid value 'boo'"
112 - lookup_config_6 is failed
113 - '"Invalid setting identifier" in lookup_config_6.msg'
114 - lookup_config_7 is failed
115 - lookup_config_7.msg is contains "No config definition exists for 'ConfigManager'"
116 - lookup_config_8 is failed
117 - '"Both plugin_type and plugin_name" in lookup_config_8.msg'
118 - lookup_config_9 is failed
119 - '"Both plugin_type and plugin_name" in lookup_config_9.msg'
120 - lookup_config_10 is failed
121 - lookup_config_10.msg is contains "No config definition exists for 'plugin_type1'"
122 - lookup_config_11 is failed
123 - '"Unable to load lookup" in lookup_config_11.msg'
124 - lookup_config_12 is failed
125 - lookup_config_12.msg is contains "Required config 'test_list' for 'bogus' lookup plugin not provided"
126 - ssh_user_and_port == ['lola', 2022]
127 - "ssh_user_and_port_and_origin == [['lola', 'var: ansible_ssh_user'], [2022, 'var: ansible_ssh_port']]"
128 - yolo_remote == ["yolo"]
129 - config_origin1[1] == "default"
130 - config_origin2[0] == 'yolo'
131 - 'config_origin2[1] == "var: _z_test_entry"'
132
133 - name: verify interdependent templating
134 assert:
135 that:
136 - lookup('config', 'ANSIBLE_HOME') == lookup('config', '_Z_TEST_ENTRY_3')