blob: b9294415dcbd52b01587ef24e66acef87486bd74 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
---
- name: Create download directory
file:
dest: "{{ raspios_download_dir }}"
state: directory
- name: fetch imageutility os list from download server
check_mode: no
uri:
url: "{{ raspios_download_url }}/os_list_imagingutility_v3.json"
body_format: json
register: raspios_os_list_imagingutility
- set_fact:
raspios_download_url_image: "{{ raspios_os_list_imagingutility.json.os_list | raspios_extract_latest_image_download_url(raspios_download_base_url) }}"
- name: download the raspios image
block:
- name: download sha256sum and signature
loop:
- sha256
- sig
get_url:
url: "{{ raspios_download_url_image }}.{{ item }}"
dest: "{{ raspios_download_dir }}/{{ raspios_download_image_base_name }}.{{ item }}"
- name: extract SHA256 hash of the image archive
command: grep '{{ raspios_download_image_base_name }}' "{{ raspios_download_dir }}/{{ raspios_download_image_base_name }}.sha256"
changed_when: False
register: sha256
- name: download image
get_url:
url: "{{ raspios_download_url_image }}"
dest: "{{ raspios_download_dir }}/{{ raspios_download_image_base_name }}"
checksum: sha256:{{ sha256.stdout.split(' ') | first }}
- name: check OpenPGP signature
command: >-
gpgv --keyring "{{ global_files_dir }}/common/keyrings/raspberrypi-downloads.gpg"
"{{ raspios_download_dir }}/{{ raspios_download_image_base_name }}.sig" "{{ raspios_download_dir }}/{{ raspios_download_image_base_name }}"
changed_when: False
register: raspios_image_gpg_result
- debug:
var: raspios_image_gpg_result.stderr_lines
rescue:
- name: delete downloaded artifacts
loop:
- "{{ raspios_download_dir }}/{{ raspios_download_image_base_name }}-sha256"
- "{{ raspios_download_dir }}/{{ raspios_download_image_base_name }}.sig"
- "{{ raspios_download_dir }}/{{ raspios_download_image_base_name }}"
file:
path: "{{ item }}"
state: absent
- name: the download has failed...
fail:
msg: Something borked
|