Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/snap/tasks/test.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Make sure package is not installed (hello-world)
7 community.general.snap:
8 name: hello-world
9 state: absent
10
11 - name: Install package (hello-world) (check mode)
12 community.general.snap:
13 name: hello-world
14 state: present
15 register: install_check
16 check_mode: true
17
18 - name: Install package (hello-world)
19 community.general.snap:
20 name: hello-world
21 state: present
22 register: install
23
24 - name: Install package again (hello-world) (check mode)
25 community.general.snap:
26 name: hello-world
27 state: present
28 register: install_again_check
29 check_mode: true
30
31 - name: Install package again (hello-world)
32 community.general.snap:
33 name: hello-world
34 state: present
35 register: install_again
36
37 - name: Assert package has been installed just once (hello-world)
38 assert:
39 that:
40 - install is changed
41 - install_check is changed
42 - install_again is not changed
43 - install_again_check is not changed
44
45 - name: Check package has been installed correctly (hello-world)
46 command: hello-world
47 environment:
48 PATH: /snap/bin/
49
50 - name: Remove package (hello-world) (check mode)
51 community.general.snap:
52 name: hello-world
53 state: absent
54 register: remove_check
55 check_mode: true
56
57 - name: Remove package (hello-world)
58 community.general.snap:
59 name: hello-world
60 state: absent
61 register: remove
62
63 - name: Remove package again (hello-world) (check mode)
64 community.general.snap:
65 name: hello-world
66 state: absent
67 register: remove_again_check
68 check_mode: true
69
70 - name: Remove package again (hello-world)
71 community.general.snap:
72 name: hello-world
73 state: absent
74 register: remove_again
75
76 - name: Assert package has been removed just once (hello-world)
77 assert:
78 that:
79 - remove is changed
80 - remove_check is changed
81 - remove_again is not changed
82 - remove_again_check is not changed
83
84 - name: Make sure package from classic snap is not installed (nvim)
85 community.general.snap:
86 name: nvim
87 state: absent
88
89 - name: Install package from classic snap (nvim)
90 community.general.snap:
91 name: nvim
92 state: present
93 classic: true
94 register: classic_install
95
96 # testing classic idempotency
97 - name: Install package from classic snap again (nvim)
98 community.general.snap:
99 name: nvim
100 state: present
101 classic: true
102 register: classic_install_again
103
104 - name: Assert package has been installed just once (nvim)
105 assert:
106 that:
107 - classic_install is changed
108 - classic_install_again is not changed
109
110 # this is just testing if a package which has been installed
111 # with true classic can be removed without setting classic to true
112 - name: Remove package from classic snap without setting classic to true (nvim)
113 community.general.snap:
114 name: nvim
115 state: absent
116 register: classic_remove_without_true_classic
117
118 - name: Remove package from classic snap with setting classic to true (nvim)
119 community.general.snap:
120 name: nvim
121 state: absent
122 classic: true
123 register: classic_remove_with_true_classic
124
125 - name: Assert package has been removed without setting classic to true (nvim)
126 assert:
127 that:
128 - classic_remove_without_true_classic is changed
129 - classic_remove_with_true_classic is not changed
130
131
132 - name: Make sure package is not installed (uhttpd)
133 community.general.snap:
134 name: uhttpd
135 state: absent
136
137 - name: Install package (uhttpd)
138 community.general.snap:
139 name: uhttpd
140 state: present
141 register: install
142
143 - name: Install package (uhttpd)
144 community.general.snap:
145 name: uhttpd
146 state: present
147 options:
148 - "listening-port=8080"
149 register: install_with_option
150
151 - name: Install package again with option (uhttpd)
152 community.general.snap:
153 name: uhttpd
154 state: present
155 options:
156 - "listening-port=8080"
157 register: install_with_option_again
158
159 - name: Install package again with different options (uhttpd)
160 community.general.snap:
161 name: uhttpd
162 state: present
163 options:
164 - "listening-port=8088"
165 - "document-root-dir=/tmp"
166 register: install_with_option_changed
167
168 - name: Remove package (uhttpd)
169 community.general.snap:
170 name: uhttpd
171 state: absent
172 register: remove
173
174 - name: Assert package has been installed with options just once and only changed options trigger a change (uhttpd)
175 assert:
176 that:
177 - install is changed
178 - install_with_option is changed
179 - "install_with_option.options_changed[0] == 'uhttpd:listening-port=8080'"
180 - install_with_option_again is not changed
181 - install_with_option_changed is changed
182 - "'uhttpd:listening-port=8088' in install_with_option_changed.options_changed"
183 - "'uhttpd:document-root-dir=/tmp' in install_with_option_changed.options_changed"
184 - "'uhttpd:listening-port=8080' not in install_with_option_changed.options_changed"
185 - remove is changed
186
187 - name: Install two packages at the same time
188 community.general.snap:
189 name:
190 - hello-world
191 - uhttpd
192 state: present
193 register: install_two
194
195 - name: Install two packages at the same time (again)
196 community.general.snap:
197 name:
198 - hello-world
199 - uhttpd
200 state: present
201 register: install_two_again
202
203 - name: Remove packages (hello-world & uhttpd)
204 community.general.snap:
205 name:
206 - hello-world
207 - uhttpd
208 state: absent
209 register: install_two_remove
210
211 - name: Remove packages again (hello-world & uhttpd)
212 community.general.snap:
213 name:
214 - hello-world
215 - uhttpd
216 state: absent
217 register: install_two_remove_again
218
219 - name: Assert installation of two packages
220 assert:
221 that:
222 - install_two is changed
223 - "'hello-world' in install_two.snaps_installed"
224 - "'uhttpd' in install_two.snaps_installed"
225 - install_two.snaps_removed is not defined
226 - install_two_again is not changed
227 - install_two_again.snaps_installed is not defined
228 - install_two_again.snaps_removed is not defined
229 - install_two_remove is changed
230 - install_two_again.snaps_installed is not defined
231 - "'hello-world' in install_two_remove.snaps_removed"
232 - "'uhttpd' in install_two_remove.snaps_removed"
233 - install_two_remove_again is not changed
234 - install_two_remove_again.snaps_installed is not defined
235 - install_two_remove_again.snaps_removed is not defined