|
10 | 10 | tasks: |
11 | 11 | # Python Installation Verification |
12 | 12 | - name: Check Python is installed |
13 | | - command: python3 --version |
| 13 | + ansible.builtin.command: python3 --version |
14 | 14 | register: python_version |
15 | 15 | changed_when: false |
16 | 16 |
|
17 | 17 | - name: Verify Python version output |
18 | | - assert: |
| 18 | + ansible.builtin.assert: |
19 | 19 | that: |
20 | 20 | - python_version.rc == 0 |
21 | 21 | - "'Python 3.' in python_version.stdout" |
|
24 | 24 |
|
25 | 25 | # Pip Installation Verification |
26 | 26 | - name: Check pip is installed |
27 | | - command: pip3 --version |
| 27 | + ansible.builtin.command: pip3 --version |
28 | 28 | register: pip_version |
29 | 29 | changed_when: false |
30 | 30 |
|
31 | 31 | - name: Verify pip version output |
32 | | - assert: |
| 32 | + ansible.builtin.assert: |
33 | 33 | that: |
34 | 34 | - pip_version.rc == 0 |
35 | 35 | - "'pip' in pip_version.stdout" |
|
38 | 38 |
|
39 | 39 | # UV Installation Verification (when enabled) |
40 | 40 | - name: Check if uv should be installed |
41 | | - set_fact: |
| 41 | + ansible.builtin.set_fact: |
42 | 42 | uv_should_be_installed: "{{ python_uv_install | default(false) }}" |
43 | 43 |
|
44 | 44 | - name: Check uv binary exists |
45 | | - stat: |
| 45 | + ansible.builtin.stat: |
46 | 46 | path: "{{ python_prefix_dir | default('/usr/local') }}/bin/uv" |
47 | 47 | register: uv_binary |
48 | 48 | when: uv_should_be_installed |
49 | 49 |
|
50 | 50 | - name: Verify uv binary is executable |
51 | | - assert: |
| 51 | + ansible.builtin.assert: |
52 | 52 | that: |
53 | 53 | - uv_binary.stat.exists |
54 | 54 | - uv_binary.stat.executable |
|
58 | 58 | when: uv_should_be_installed |
59 | 59 |
|
60 | 60 | - name: Check uvx binary exists |
61 | | - stat: |
| 61 | + ansible.builtin.stat: |
62 | 62 | path: "{{ python_prefix_dir | default('/usr/local') }}/bin/uvx" |
63 | 63 | register: uvx_binary |
64 | 64 | when: uv_should_be_installed |
65 | 65 |
|
66 | 66 | - name: Verify uvx binary is executable |
67 | | - assert: |
| 67 | + ansible.builtin.assert: |
68 | 68 | that: |
69 | 69 | - uvx_binary.stat.exists |
70 | 70 | - uvx_binary.stat.executable |
|
74 | 74 | when: uv_should_be_installed |
75 | 75 |
|
76 | 76 | - name: Test uv command execution |
77 | | - command: "{{ python_prefix_dir | default('/usr/local') }}/bin/uv --version" |
| 77 | + ansible.builtin.command: "{{ python_prefix_dir | default('/usr/local') }}/bin/uv --version" |
78 | 78 | register: uv_version_check |
79 | 79 | changed_when: false |
80 | 80 | when: uv_should_be_installed |
81 | 81 |
|
82 | 82 | - name: Verify uv version output |
83 | | - assert: |
| 83 | + ansible.builtin.assert: |
84 | 84 | that: |
85 | 85 | - uv_version_check.rc == 0 |
86 | 86 | - "'uv' in uv_version_check.stdout" |
|
90 | 90 | when: uv_should_be_installed |
91 | 91 |
|
92 | 92 | - name: Test uvx command execution |
93 | | - command: "{{ python_prefix_dir | default('/usr/local') }}/bin/uvx --version" |
| 93 | + ansible.builtin.command: "{{ python_prefix_dir | default('/usr/local') }}/bin/uvx --version" |
94 | 94 | register: uvx_version_check |
95 | 95 | changed_when: false |
96 | 96 | when: uv_should_be_installed |
97 | 97 |
|
98 | 98 | - name: Verify uvx version output |
99 | | - assert: |
| 99 | + ansible.builtin.assert: |
100 | 100 | that: |
101 | 101 | - uvx_version_check.rc == 0 |
102 | 102 | - "'uvx' in uvx_version_check.stdout" |
|
106 | 106 |
|
107 | 107 | # Architecture Detection Verification |
108 | 108 | - name: Get system architecture |
109 | | - command: uname -m |
| 109 | + ansible.builtin.command: uname -m |
110 | 110 | register: system_arch |
111 | 111 | changed_when: false |
112 | 112 |
|
113 | 113 | - name: Verify architecture was detected correctly |
114 | | - debug: |
| 114 | + ansible.builtin.debug: |
115 | 115 | msg: "System architecture detected as: {{ system_arch.stdout }}" |
116 | 116 |
|
117 | 117 | # Permissions Verification |
118 | 118 | - name: Check file permissions in install directory |
119 | | - find: |
| 119 | + ansible.builtin.find: |
120 | 120 | paths: "{{ python_prefix_dir | default('/usr/local') }}/bin" |
121 | 121 | patterns: "uv*" |
122 | 122 | register: uv_files |
123 | 123 | when: uv_should_be_installed |
124 | 124 |
|
125 | 125 | - name: Verify all uv files have correct permissions |
126 | | - assert: |
| 126 | + ansible.builtin.assert: |
127 | 127 | that: |
128 | 128 | - "item.mode is defined and (item.mode | string) | regex_search('755$')" |
129 | 129 | fail_msg: "UV file {{ item.path }} has incorrect permissions: {{ item.mode }}" |
|
133 | 133 |
|
134 | 134 | # Idempotency Test Setup (verify no temp files left behind) |
135 | 135 | - name: Check for leftover temporary files |
136 | | - find: |
| 136 | + ansible.builtin.find: |
137 | 137 | paths: /tmp |
138 | 138 | patterns: "*uv*" |
139 | 139 | file_type: any |
140 | 140 | register: temp_uv_files |
141 | 141 |
|
142 | 142 | - name: Verify no temporary UV files left behind |
143 | | - assert: |
| 143 | + ansible.builtin.assert: |
144 | 144 | that: |
145 | 145 | - temp_uv_files.files | length == 0 |
146 | 146 | fail_msg: "Temporary UV files found: {{ temp_uv_files.files | map(attribute='path') | list }}" |
147 | 147 | success_msg: "No temporary UV files left behind - good cleanup" |
148 | 148 |
|
149 | 149 | # Final Success Summary |
150 | 150 | - name: Display verification summary |
151 | | - debug: |
| 151 | + ansible.builtin.debug: |
152 | 152 | msg: | |
153 | 153 | ✅ anxs-python Role Verification Complete! |
154 | 154 |
|
|
0 commit comments