|
112 | 112 | chdir: "{{ topdir_path }}" |
113 | 113 | when: ci_results.stdout_lines | length > 0 |
114 | 114 |
|
115 | | -- name: Create our archive/ tar.xz for our test results |
| 115 | +- name: Create our archive/ xz file for kdevops-results-archive |
116 | 116 | archive: |
117 | 117 | path: "{{ kdevops_results_local }}" |
118 | 118 | dest: "{{ kdevops_results }}/{{ target_linux_ref }}.xz" |
119 | 119 | format: xz |
120 | 120 | remove: no |
121 | 121 |
|
122 | | -- name: Create the same zip archive as well |
| 122 | +- name: Create the same archive/ zip file for web CI artifacts |
123 | 123 | archive: |
124 | 124 | path: "{{ kdevops_results_local }}" |
125 | 125 | dest: "{{ kdevops_results }}/{{ target_linux_ref }}.zip" |
126 | 126 | format: zip |
127 | 127 | remove: no |
128 | 128 |
|
129 | | -- name: Get SSH configuration for the kdevops archive repo |
130 | | - ansible.builtin.command: ssh -G {{ kdevops_results_repo_url_user }}@{{ kdevops_results_repo_path }} |
131 | | - register: ssh_archive_config_repo |
132 | | - changed_when: false |
133 | | - |
134 | | -- name: Extract kdevops archive repo IdentityFile |
135 | | - vars: |
136 | | - identity_file_lines: "{{ ssh_archive_config_repo.stdout_lines | select('match', '^identityfile ') }}" |
137 | | - identity_file_raw: "{{ identity_file_lines | first | regex_replace('^identityfile (.*)$', '\\1') }}" |
138 | | - ansible.builtin.set_fact: |
139 | | - kdevops_archive_identity_file: "{{ identity_file_raw | regex_replace('^~', lookup('env', 'HOME')) }}" |
140 | | - |
141 | | -- name: Check if the key used for the kdevops archive repo is installed |
142 | | - ansible.builtin.set_fact: |
143 | | - kdevops_archive_key_detected: "{{ kdevops_archive_key_name in (kdevops_archive_identity_file | basename) }}" |
144 | | - |
145 | | -- name: Inform user of how to set up the kdevops archive repo key |
146 | | - ansible.builtin.debug: |
147 | | - msg: | |
148 | | - ssh key archive test for {{ kdevops_results_repo_url }}: |
149 | | - We ran: |
150 | | -
|
151 | | - ssh -G {{ kdevops_results_repo_url_user }}@{{ kdevops_results_repo_path }} | grep identityfile |
152 | | -
|
153 | | - Missing key name: '{{ kdevops_archive_key_name }}' |
154 | | - Current IdentityFile: |
155 | | - {{ kdevops_archive_identity_file }} |
156 | | -
|
157 | | - To set up automatic kdevops repo archiving install something like |
158 | | - the following key for host {{ kdevops_archive_host }}: |
159 | | -
|
160 | | - Host {{ kdevops_results_repo_path }} |
161 | | - User {{ kdevops_results_repo_url_user }} |
162 | | - Hostname {{ kdevops_archive_host }} |
163 | | - IdentityFile {{ lookup('env', 'HOME') }}/.ssh/{{ kdevops_archive_key_name }} |
164 | | -
|
165 | | -
|
166 | | - Create the key first with something like: |
167 | | -
|
168 | | - ssh-keygen -t ed25519 -C "{{ kdevops_results_repo_url_user}}@{{ kdevops_results_repo_path }}" -f {{ lookup('env', 'HOME') }}/.ssh/{{ kdevops_archive_key_name }} |
169 | | -
|
170 | | - Then install it as deploy key for {{ kdevops_results_repo_path}}: |
171 | | -
|
172 | | - https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys#deploy-keys |
173 | | -
|
174 | | - And then add the above to your {{ lookup('env', 'HOME') }}/.ssh/config |
175 | | -
|
176 | | - when: |
177 | | - - 'not kdevops_archive_key_detected|bool' |
178 | | - - 'bootlinux_tree_set_by_cli|bool' |
179 | | - |
180 | | -- name: Gracefully end if key is not found for automatic kdevops archiving |
181 | | - meta: end_play |
182 | | - when: |
183 | | - - not kdevops_archive_key_detected |
184 | | - |
185 | | -- name: Check if the detected kdevops archive repo key exists |
186 | | - ansible.builtin.stat: |
187 | | - path: "{{ kdevops_archive_identity_file }}" |
188 | | - register: ssh_key_file_lookup |
189 | | - |
190 | | -- name: Inform user of configured but not created key |
191 | | - ansible.builtin.debug: |
192 | | - msg: | |
193 | | - Key to be used missing: {{ kdevops_archive_identity_file }} |
194 | | - Create the key with something like: |
195 | | - ssh-keygen -t ed25519 -C "{{ kdevops_results_repo_url_user}}@{{ kdevops_results_repo_path }}" -f {{ lookup('env', 'HOME') }}/.ssh/{{ kdevops_archive_key_name }} |
196 | | - when: |
197 | | - - not ssh_key_file_lookup.stat.exists |
198 | | - |
199 | | -- name: Gracefully end if key does not exist |
200 | | - meta: end_play |
201 | | - when: |
202 | | - - not ssh_key_file_lookup.stat.exists |
| 129 | +- name: Find archive files to verify |
| 130 | + find: |
| 131 | + paths: "{{ kdevops_results }}" |
| 132 | + patterns: |
| 133 | + - "*.zip" |
| 134 | + - "*.xz" |
| 135 | + register: archive_files |
203 | 136 |
|
204 | | -- name: Check if kdevops results archive ssh key has a passphrase |
205 | | - ansible.builtin.command: |
206 | | - cmd: "ssh-keygen -y -f {{ kdevops_archive_identity_file }}" |
207 | | - register: ssh_key_check |
208 | | - ignore_errors: yes |
| 137 | +- name: Get archive file stat |
| 138 | + stat: |
| 139 | + path: "{{ item.path }}" |
| 140 | + register: archive_stats |
| 141 | + loop: "{{ archive_files.files }}" |
209 | 142 | changed_when: false |
210 | | - failed_when: false |
211 | 143 | no_log: true |
212 | 144 |
|
213 | | -- name: Set fact about SSH key passphrase status |
214 | | - ansible.builtin.set_fact: |
215 | | - kdevops_archive_key_has_passphrase: "{{ ssh_key_check.rc != 0 }}" |
216 | | - |
217 | | -- name: Inform user if key did not have a passphrase |
218 | | - ansible.builtin.debug: |
219 | | - msg: | |
220 | | - ssh key archive {{ kdevops_archive_identity_file }} for {{ kdevops_results_repo_url }} |
221 | | - does not have a passphrase. This not secure and not allowed. Giving up. |
222 | | - when: |
223 | | - - 'not kdevops_archive_key_has_passphrase|bool' |
224 | | - |
225 | | -- name: End if key did not have passphrase set up |
226 | | - meta: end_play |
227 | | - when: |
228 | | - - 'not kdevops_archive_key_has_passphrase|bool' |
229 | | - |
230 | | -- name: Gracefully end if the user did not set up a kdevops archive repo key |
231 | | - meta: end_play |
232 | | - when: not kdevops_archive_key_detected |
233 | | - |
234 | | -- name: Get fingerprint of the identity file for {{ kdevops_archive_key_name }} |
235 | | - ansible.builtin.command: ssh-keygen -lf "{{ kdevops_archive_identity_file }}" |
236 | | - register: kdevops_archive_fingerprint_output |
237 | | - changed_when: false |
238 | | - when: |
239 | | - - 'kdevops_archive_key_detected|bool' |
240 | | - |
241 | | -- name: Extract the {{ kdevops_archive_key_name }} fingerprint |
242 | | - ansible.builtin.set_fact: |
243 | | - kdevops_archive_key_fingerprint: "{{ kdevops_archive_fingerprint_output.stdout.split()[1] }}" |
244 | | - when: |
245 | | - - 'kdevops_archive_key_detected|bool' |
246 | | - |
247 | | -- name: List keys in ssh-agent |
248 | | - ansible.builtin.command: ssh-add -l |
249 | | - register: kdevops_archive_ssh_add_list |
250 | | - changed_when: false |
251 | | - when: |
252 | | - - 'kdevops_archive_key_detected|bool' |
253 | | - |
254 | | -- name: Check if key is loaded in ssh-agent |
255 | | - ansible.builtin.set_fact: |
256 | | - kdevops_archive_key_loaded: "{{ kdevops_archive_key_fingerprint in kdevops_archive_ssh_add_list.stdout }}" |
257 | | - |
258 | | -- name: Inform when we are achiving |
259 | | - ansible.builtin.debug: |
260 | | - msg: "Achievement unlocked: kdevops archive key set up, automatic kdevops archiving enabled." |
261 | | - when: |
262 | | - - 'kdevops_archive_key_loaded|bool' |
| 145 | +- name: Display archive file information |
| 146 | + debug: |
| 147 | + msg: "{{ item.stat.path }} ({{ (item.stat.size / 1024 / 1024) | round(2) }}MB)" |
| 148 | + loop: "{{ archive_stats.results }}" |
| 149 | + loop_control: |
| 150 | + label: "{{ item.stat.path | basename }}" |
263 | 151 |
|
264 | 152 | - name: Check if kdevops-results-archive directory exists |
265 | 153 | stat: |
|
0 commit comments