summaryrefslogtreecommitdiff
path: root/roles/installer/debian/fetch/tasks/main.yml
blob: 1fbd96064f7e600ac2060d219d9daa5170a24a4c (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
---
- name: compute target directory
  set_fact:
    debian_installer_target_dir: "{{ installer_base_path }}/{{ debian_installer_distro }}-{{ debian_installer_codename }}/{{ debian_installer_arch }}-{{ debian_installer_variant }}"

- name: prepare directories for installer files
  file:
    name: "{{ debian_installer_target_dir }}"
    state: directory

- name: download and verify installer files
  block:
  - name: fetch and verify installer checksum file
    include_tasks: "verify-{{ debian_installer_distro }}.yml"

  - name: extract file hashes from SHA256SUMS
    loop: "{{ debian_installer_variant_files }}"
    command: grep -E "^[0-9a-z]{64}\s+(./)?{{ debian_installer_variant_path }}/{{ item }}$" "{{ debian_installer_target_dir }}/SHA256SUMS"
    changed_when: false
    register: debian_installer_sha256sums

  - name: download installer files
    loop: "{{ debian_installer_sha256sums.results }}"
    loop_control:
      label: "{{ item.item }}"
    get_url:
      url: "{{ debian_installer_base_url }}/{{ debian_installer_variant_path }}/{{ item.item }}"
      dest: "{{ debian_installer_target_dir }}/{{ item.item }}"
      checksum: "sha256:{{ item.stdout.split(' ') | first }}"
      mode: 0644

  rescue:
  - name: remove all downloaded files
    file:
      name: "{{ debian_installer_target_dir }}"
      state: absent

  - fail:
      msg: "download/verification of installer files failed"