summaryrefslogtreecommitdiff
path: root/roles/installer/ubuntu/fetch/tasks/main.yml
blob: ff87fb64278e4a54d3872041e7fcb85da124dcdf (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
---
- when: ubuntu_installer_version is undefined
  include_tasks: determine-latest-version.yml

- name: compute target directory
  set_fact:
    ubuntu_installer_target_dir: "{{ installer_base_path }}/{{ ubuntu_installer_codename }}/{{ ubuntu_installer_version }}-{{ ubuntu_installer_variant }}"

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

- name: find download location for release version
  import_tasks: find-location.yml

- name: verfiy signature of SHA256SUMS file
  command: >-
    gpgv --keyring "{{ installer_keyrings_path | default(installer_base_path+'/keyrings') }}/ubuntu-cdimage.gpg"
         "{{ ubuntu_installer_target_dir }}/SHA256SUMS.gpg" "{{ ubuntu_installer_target_dir }}/SHA256SUMS"
  changed_when: False
  register: ubuntu_installer_gpg_result

- debug:
    var: ubuntu_installer_gpg_result.stderr_lines


- name: download and verify installer files
  block:
  - name: extract file hash from SHA256SUMS
    command: grep -E '^[0-9a-z]{64}\s+\*ubuntu-{{ ubuntu_installer_version | default("[0-9.]+") }}-{{ ubuntu_installer_variant }}-{{ ubuntu_installer_arch }}.iso$' "{{ ubuntu_installer_target_dir }}/SHA256SUMS"
    changed_when: false
    register: ubuntu_installer_sha256sum

  - name: extract filename from SHA256SUM
    set_fact:
      ubuntu_installer_filename: "{{ (ubuntu_installer_sha256sum.stdout.split(' ') | last)[1:] }}"

  - debug:
      msg: "will be downloading: {{ ubuntu_installer_base_url }}/{{ ubuntu_installer_filename }} (this will probably take a while...)"

  - name: download/verify installer file
    get_url:
      url: "{{ ubuntu_installer_base_url }}/{{ ubuntu_installer_filename }}"
      dest: "{{ ubuntu_installer_target_dir }}/{{ ubuntu_installer_filename }}"
      checksum: "sha256:{{ ubuntu_installer_sha256sum.stdout.split(' ') | first }}"
      force: "{{ ubuntu_installer_force_download }}"

  rescue:
  - fail:
      msg: "download/verification of installer files failed. Is the cd-image variant '{{ ubuntu_installer_variant }}' available for {{ ubuntu_installer_codename }}?"