Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/uv_python/tasks/main.yaml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Copyright (c) Ansible Project
8 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # SPDX-License-Identifier: GPL-3.0-or-later
10
11 - name: Install uv python package
12 ansible.builtin.pip:
13 name: uv
14
15 - name: Install uv in RHEL
16 when: ansible_facts['os_family'] == "RedHat"
17 shell: |
18 curl -LsSf https://astral.sh/uv/install.sh | sh
19 environment:
20 UV_INSTALL_DIR: "{{ ansible_env.HOME }}/ansible/bin"
21 args:
22 creates: "{{ ansible_env.HOME }}/ansible/bin/uv"
23
24 - name: Check if Python 3.14 exists already
25 command: uv python find 3.14
26 ignore_errors: true
27 register: check_python_314_exists
28 changed_when: false
29
30 - name: Install Python 3.14 in check mode
31 uv_python:
32 version: "3.14"
33 state: present
34 check_mode: true
35 register: install_check_mode
36
37 - name: Verify Python 3.14 installation in check mode
38 assert:
39 that:
40 - (install_check_mode is changed) == (check_python_314_exists is failed)
41 - install_check_mode is not failed
42 - install_check_mode.python_versions | length >= 1
43
44 - name: Install Python 3.14
45 uv_python:
46 version: "3.14"
47 state: present
48 register: install_python
49
50 - name: Verify Python 3.14 installation
51 assert:
52 that:
53 - install_python.changed == check_python_314_exists.failed
54 - install_python.failed is false
55 - install_python.python_versions | length >= 1
56 - install_python.python_paths | length >= 1
57
58 - name: Get Python install path stats
59 ansible.builtin.stat:
60 path: "{{ install_python.python_paths[0] }}"
61 follow: true
62 register: python_path_stats
63
64 - name: Verify that Python 3.14 install path exists on host
65 ansible.builtin.fail:
66 msg: "Python install path {{ install_python.python_paths[0] }} is not correct"
67 when: not python_path_stats.stat.exists
68
69 - name: Re-install Python 3.14
70 uv_python:
71 version: "3.14"
72 state: present
73 register: reinstall_python
74
75 - name: Verify Python 3.14 re-installation
76 assert:
77 that:
78 - reinstall_python is not changed
79 - reinstall_python is not failed
80 - reinstall_python.python_versions | length >= 1
81 - reinstall_python.python_paths | length >= 1
82
83 - name: Check if Python 3.13.5 exists already
84 command: uv python find 3.13.5
85 ignore_errors: true
86 register: check_python_3135_exists
87 changed_when: false
88
89 - name: Install Python 3.13.5
90 uv_python:
91 version: 3.13.5
92 register: install_python_3135
93
94 - name: Verify Python 3.13.5 installation
95 assert:
96 that:
97 - install_python_3135.changed == check_python_3135_exists.failed
98 - install_python_3135.failed is false
99 - '"3.13.5" in install_python_3135.python_versions'
100 - install_python_3135.python_paths | length >= 1
101
102 - name: Re-install Python 3.13.5
103 uv_python:
104 version: 3.13.5
105 state: present
106 register: reinstall_python
107
108 - name: Verify Python 3.13.5 installation
109 assert:
110 that:
111 - reinstall_python.changed is false
112 - reinstall_python.failed is false
113 - '"3.13.5" in reinstall_python.python_versions'
114
115 - name: Remove uninstalled Python 3.10 # removes latest patch version for 3.10 if exists
116 uv_python:
117 version: "3.10"
118 state: absent
119 register: remove_python
120
121 - name: Verify Python 3.10 deletion
122 assert:
123 that:
124 - remove_python.changed is false
125 - remove_python.failed is false
126 - remove_python.python_versions | length == 0
127
128 - name: Remove Python 3.13.5 in check mode
129 uv_python:
130 version: 3.13.5
131 state: absent
132 check_mode: true
133 register: remove_python_in_check_mode
134
135 - name: Verify Python 3.13.5 deletion in check mode
136 assert:
137 that:
138 - remove_python_in_check_mode.changed == install_python_3135.changed
139 - remove_python_in_check_mode.failed is false
140
141 - name: Additional check for Python 3.13.5 deletion in check mode
142 when: install_python_3135.changed is true
143 assert:
144 that:
145 - '"3.13.5" in remove_python_in_check_mode.python_versions'
146 - remove_python_in_check_mode.python_paths | length >= 1
147
148 - name: Remove Python 3.13.5
149 uv_python:
150 version: 3.13.5
151 state: absent
152 register: remove_python
153
154 - name: Verify Python 3.13.5 deletion
155 assert:
156 that:
157 - remove_python.changed == install_python_3135.changed
158 - remove_python.failed is false
159
160 - name: Additional check for Python 3.13.5 deletion
161 when: install_python_3135.changed is true
162 assert:
163 that:
164 - remove_python.python_paths | length >= 1
165 - '"3.13.5" in remove_python.python_versions'
166
167 - name: Remove Python 3.13.5 again
168 uv_python:
169 version: 3.13.5
170 state: absent
171 register: remove_python
172
173 - name: Verify Python 3.13.5 deletion again
174 assert:
175 that:
176 - remove_python.changed is false
177 - remove_python.failed is false
178 - remove_python.python_versions | length == 0
179 - remove_python.python_paths | length == 0
180
181 - name: Upgrade Python 3.13
182 uv_python:
183 version: 3.13
184 state: latest
185 register: upgrade_python
186
187 - name: Verify Python 3.13 upgrade
188 assert:
189 that:
190 - upgrade_python.changed is true
191 - upgrade_python.failed is false
192 - upgrade_python.python_versions | length >= 1
193 - upgrade_python.python_paths | length >= 1
194
195 - name: Upgrade Python 3.13 in check mode
196 uv_python:
197 version: 3.13
198 state: latest
199 check_mode: true
200 register: upgrade_python
201
202 - name: Verify Python 3.13 upgrade in check mode
203 assert:
204 that:
205 - upgrade_python.changed is false
206 - upgrade_python.failed is false
207 - upgrade_python.python_versions | length >= 1
208
209 - name: Upgrade Python 3.13 again
210 uv_python:
211 version: 3.13
212 state: latest
213 check_mode: true
214 register: upgrade_python
215
216 - name: Verify Python 3.13 upgrade again
217 assert:
218 that:
219 - upgrade_python.changed is false
220 - upgrade_python.failed is false
221 - upgrade_python.python_versions | length >= 1
222
223 - name: Install unsupported Python version in check mode
224 uv_python:
225 version: 2.0
226 state: present
227 register: unsupported_python_check_mode
228 ignore_errors: true
229 check_mode: true
230
231 - name: Verify unsupported Python 2.0 install in check mode
232 assert:
233 that:
234 - unsupported_python_check_mode.changed is false
235 - unsupported_python_check_mode.failed is true
236 - '"Version 2.0 is not available." in unsupported_python_check_mode.msg'
237
238 - name: Install unsupported Python version
239 uv_python:
240 state: present
241 version: 2.0
242 register: unsupported_python
243 ignore_errors: true
244
245 - name: Verify unsupported Python 2.0 install
246 assert:
247 that:
248 - unsupported_python.changed is false
249 - unsupported_python.failed is true
250
251 - name: Install unsupported Python version with latest state
252 uv_python:
253 version: "2.0"
254 state: latest
255 register: unsupported_python
256 ignore_errors: true
257
258 - name: Verify Python 2.0 install with latest state
259 assert:
260 that:
261 - unsupported_python.changed is false
262 - unsupported_python.failed is true
263
264 - name: Delete Python 3.13 version
265 uv_python:
266 version: "3.13"
267 state: absent
268 register: uninstall_result
269
270 - name: Verify Python 3.13 deletion
271 assert:
272 that:
273 - uninstall_result.changed is true
274 - uninstall_result.failed is false
275 - uninstall_result.python_versions | length >= 1
276 - '"3.13" in uninstall_result.python_versions[0]'
277
278 - name: No specified version
279 uv_python:
280 state: latest
281 version: ""
282 ignore_errors: true
283 register: no_version
284
285 - name: Verify failure when no version is specified
286 assert:
287 that:
288 - no_version.failed is true
289 - '"Unsupported version format" in no_version.msg'
290
291 - name: Unsupported version format given
292 uv_python:
293 state: latest
294 version: "3.8.post2"
295 ignore_errors: true
296 register: wrong_version
297
298 - name: Verify failure when unsupported version format is specified
299 assert:
300 that:
301 - wrong_version.failed is true
302 - '"Unsupported version format" in wrong_version.msg'