Debian Codegraph @

ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/test.yml

raw symbols SCIP
1 # Copyright: (c) 2019, Hetzner Cloud GmbH <[email protected]>
2 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3 ---
4 - name: Gather hcloud_image_info
5 hetzner.hcloud.image_info:
6 register: result
7 - name: Verify hcloud_image_info
8 ansible.builtin.assert:
9 that:
10 - result.hcloud_image_info | list | count >= 3
11
12 - name: Gather hcloud_image_info with architecture
13 hetzner.hcloud.image_info:
14 architecture: arm
15 register: result
16 - name: Verify hcloud_image_info with architecture
17 ansible.builtin.assert:
18 that:
19 - result.hcloud_image_info | selectattr('architecture', 'equalto', 'x86') | list | count == 0
20 - result.hcloud_image_info | selectattr('architecture', 'equalto', 'arm') | list | count > 2
21
22 - name: Gather hcloud_image_info in check mode
23 hetzner.hcloud.image_info:
24 check_mode: true
25 register: result
26 - name: Verify hcloud_image_info in check mode
27 ansible.builtin.assert:
28 that:
29 - result.hcloud_image_info | list | count >= 3
30
31 - name: Gather hcloud_image_info with correct id
32 hetzner.hcloud.image_info:
33 id: "{{ test_snapshot_id }}"
34 type: snapshot
35 register: result
36 - name: Verify hcloud_image_info with correct id
37 ansible.builtin.assert:
38 that:
39 - result.hcloud_image_info | list | count == 1
40
41 - name: Gather hcloud_image_info with wrong id
42 hetzner.hcloud.image_info:
43 id: "{{ test_snapshot_id }}4321"
44 type: snapshot
45 ignore_errors: true
46 register: result
47 - name: Verify hcloud_image_info with wrong id
48 ansible.builtin.assert:
49 that:
50 - result is failed
51
52 - name: Gather hcloud_image_info with correct name
53 hetzner.hcloud.image_info:
54 name: "{{ hcloud_image_name }}"
55 register: result
56 - name: Verify hcloud_image_info with correct name
57 ansible.builtin.assert:
58 that:
59 - result.hcloud_image_info | list | count == 1
60 - result.hcloud_image_info[0].architecture == "x86"
61
62 - name: Gather hcloud_image_info with wrong name
63 hetzner.hcloud.image_info:
64 name: "{{ hcloud_image_name }}-invalid"
65 register: result
66 - name: Verify hcloud_image_info with wrong name
67 ansible.builtin.assert:
68 that:
69 - result.hcloud_image_info | list | count == 0
70
71 - name: Gather hcloud_image_info with correct name and architecture
72 hetzner.hcloud.image_info:
73 name: "{{ hcloud_image_name }}"
74 architecture: arm
75 register: result
76 - name: Verify hcloud_image_info with correct name
77 ansible.builtin.assert:
78 that:
79 - result.hcloud_image_info | list | count == 1
80 - result.hcloud_image_info[0].architecture == "arm"
81
82 - name: Gather hcloud_image_info with correct label selector
83 hetzner.hcloud.image_info:
84 label_selector: "key=value"
85 type: snapshot
86 register: result
87 - name: Verify hcloud_image_info with correct label selector
88 ansible.builtin.assert:
89 that:
90 # Snapshot names are stored in the description field
91 - >
92 result.hcloud_image_info
93 | selectattr('description', 'equalto', hcloud_snapshot_name)
94 | list | count == 1
95
96 - name: Gather hcloud_image_info with wrong label selector
97 hetzner.hcloud.image_info:
98 label_selector: "key!=value"
99 type: snapshot
100 register: result
101 - name: Verify hcloud_image_info with wrong label selector
102 ansible.builtin.assert:
103 that:
104 - result.hcloud_image_info | list | count == 0