Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/pacman/tasks/package_urls.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 - vars:
7 http_port: 27617
8 reg_pkg: ed
9 url_pkg: lemon
10 url_pkg_filename: url.pkg.zst
11 url_pkg_path: '/tmp/'
12 url_pkg_url: 'http://localhost:{{http_port}}/{{url_pkg_filename}}'
13 file_pkg: hdparm
14 file_pkg_path: /tmp/file.pkg.zst
15 extra_pkg: core/sdparm
16 extra_pkg_outfmt: sdparm
17 block:
18 - name: Make sure that test packages are not installed
19 pacman:
20 name:
21 - '{{reg_pkg}}'
22 - '{{url_pkg}}'
23 - '{{file_pkg}}'
24 - '{{extra_pkg}}'
25 state: absent
26 - name: Make sure that url package is not cached
27 file:
28 path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
29 state: absent
30
31 - name: Get URL for {{url_pkg}}
32 command:
33 cmd: pacman --sync --print-format "%l" {{url_pkg}}
34 register: url_pkg_stdout
35 - name: Download {{url_pkg}} pkg
36 get_url:
37 url: '{{url_pkg_stdout.stdout}}'
38 dest: '{{url_pkg_path}}/{{url_pkg_filename}}'
39 - name: Download {{url_pkg}} pkg sig
40 get_url:
41 url: '{{url_pkg_stdout.stdout}}.sig'
42 dest: '{{url_pkg_path}}/{{url_pkg_filename}}.sig'
43 - name: Host {{url_pkg}}
44 shell:
45 cmd: 'python -m http.server --directory {{url_pkg_path}} {{http_port}} >/dev/null 2>&1'
46 async: 90
47 poll: 0
48 - name: Wait for http.server to come up online
49 wait_for:
50 host: 'localhost'
51 port: '{{http_port}}'
52 state: started
53
54 - name: Get URL for {{file_pkg}}
55 command:
56 cmd: pacman --sync --print-format "%l" {{file_pkg}}
57 register: file_pkg_url
58 - name: Download {{file_pkg}} pkg
59 get_url:
60 url: '{{file_pkg_url.stdout}}'
61 dest: '{{file_pkg_path}}'
62
63 - name: Install packages from mixed sources (check mode)
64 pacman:
65 name:
66 - '{{reg_pkg}}'
67 - '{{url_pkg_url}}'
68 - '{{file_pkg_path}}'
69 check_mode: true
70 register: install_1
71
72 - name: Install packages from url (check mode, cached)
73 pacman:
74 name:
75 - '{{url_pkg_url}}'
76 check_mode: true
77 register: install_1c
78 - name: Delete cached {{url_pkg}}
79 file:
80 path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
81 state: absent
82
83 - name: Install packages from mixed sources
84 pacman:
85 name:
86 - '{{reg_pkg}}'
87 - '{{url_pkg_url}}'
88 - '{{file_pkg_path}}'
89 register: install_2
90 - name: Delete cached {{url_pkg}}
91 file:
92 path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
93 state: absent
94
95 - name: Install packages from mixed sources - (idempotency)
96 pacman:
97 name:
98 - '{{reg_pkg}}'
99 - '{{url_pkg_url}}'
100 - '{{file_pkg_path}}'
101 register: install_3
102 - name: Install packages from url - (idempotency, cached)
103 pacman:
104 name:
105 - '{{url_pkg_url}}'
106 register: install_3c
107 - name: Delete cached {{url_pkg}}
108 file:
109 path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
110 state: absent
111
112 - name: Install packages with their regular names (idempotency)
113 pacman:
114 name:
115 - '{{reg_pkg}}'
116 - '{{url_pkg}}'
117 - '{{file_pkg}}'
118 register: install_4
119 - name: Delete cached {{url_pkg}}
120 file:
121 path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
122 state: absent
123
124 - name: Install new package with already installed packages from mixed sources
125 pacman:
126 name:
127 - '{{reg_pkg}}'
128 - '{{url_pkg_url}}'
129 - '{{file_pkg_path}}'
130 - '{{extra_pkg}}'
131 register: install_5
132 - name: Delete cached {{url_pkg}}
133 file:
134 path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
135 state: absent
136
137 - name: Uninstall packages - mixed sources (check mode)
138 pacman:
139 state: absent
140 name:
141 - '{{reg_pkg}}'
142 - '{{url_pkg_url}}'
143 - '{{file_pkg_path}}'
144 check_mode: true
145 register: uninstall_1
146 - name: Uninstall packages - url (check mode, cached)
147 pacman:
148 state: absent
149 name:
150 - '{{url_pkg_url}}'
151 check_mode: true
152 register: uninstall_1c
153 - name: Delete cached {{url_pkg}}
154 file:
155 path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
156 state: absent
157
158 - name: Uninstall packages - mixed sources
159 pacman:
160 state: absent
161 name:
162 - '{{reg_pkg}}'
163 - '{{url_pkg_url}}'
164 - '{{file_pkg_path}}'
165 register: uninstall_2
166 - name: Delete cached {{url_pkg}}
167 file:
168 path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
169 state: absent
170
171 - name: Uninstall packages - mixed sources (idempotency)
172 pacman:
173 state: absent
174 name:
175 - '{{reg_pkg}}'
176 - '{{url_pkg_url}}'
177 - '{{file_pkg_path}}'
178 register: uninstall_3
179
180 - name: Uninstall package - url (idempotency, cached)
181 pacman:
182 state: absent
183 name:
184 - '{{url_pkg_url}}'
185 register: uninstall_3c
186
187 - assert:
188 that:
189 - install_1 is changed
190 - install_1.msg == 'Would have installed 3 packages'
191 - install_1.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
192 - install_1c is changed
193 - install_1c.msg == 'Would have installed 1 packages'
194 - install_1c.packages|sort() == [url_pkg]
195 - install_2 is changed
196 - install_2.msg == 'Installed 3 package(s)'
197 - install_2.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
198 - install_3 is not changed
199 - install_3.msg == 'package(s) already installed'
200 - install_3c is not changed
201 - install_3c.msg == 'package(s) already installed'
202 - install_4 is not changed
203 - install_4.msg == 'package(s) already installed'
204 - install_5 is changed
205 - install_5.msg == 'Installed 1 package(s)'
206 - install_5.packages == [extra_pkg_outfmt]
207 - uninstall_1 is changed
208 - uninstall_1.msg == 'Would have removed 3 packages'
209 - uninstall_1.packages | length() == 3 # pkgs have versions here
210 - uninstall_1c is changed
211 - uninstall_1c.msg == 'Would have removed 1 packages'
212 - uninstall_1c.packages | length() == 1 # pkgs have versions here
213 - uninstall_2 is changed
214 - uninstall_2.msg == 'Removed 3 package(s)'
215 - uninstall_2.packages | length() == 3
216 - uninstall_3 is not changed
217 - uninstall_3.msg == 'package(s) already absent'
218 - uninstall_3c is not changed
219 - uninstall_3c.msg == 'package(s) already absent'