summaryrefslogtreecommitdiff
path: root/roles/installer/debian/fetch/tasks/main.yml
blob: 0e75641122e3c93a2d19f2d645a4598076c79a19 (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
---
- 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-{{ install_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 }}"
      force: "{{ debian_installer_force_download }}"
      mode: 0644

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

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