summaryrefslogtreecommitdiff
path: root/roles/installer/ubuntu/fetch/tasks/find-location.yml
blob: 752eebe1e9cb6fe912ecbec42a161aa76c7c5b5f (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
---
## we need to try old-releases.ubuntu.com first because otherwise it would be impossible to download the initial release
## of any codename release. (i.e. 20.04)
- name: try downloading SHA256SUMS and signature file from old-releases.ubuntu.com
  loop:
  - SHA256SUMS
  - SHA256SUMS.gpg
  get_url:
    url: "https://old-releases.ubuntu.com/releases/{{ ubuntu_installer_codename }}/{{ item }}"
    dest: "{{ ubuntu_installer_target_dir }}/{{ item }}"
    force: yes
  register: ubuntu_installer_old
  failed_when: "'status_code' in ubuntu_installer_old and ubuntu_installer_old.status_code not in [200, 404]"

- when: 404 not in (ubuntu_installer_old.results | selectattr('status_code', 'defined') | map(attribute='status_code') | list)
  block:
  - name: check if SHA256SUM actually contains the correct iso
    command: grep -E '^[0-9a-z]{64}\s+\*ubuntu-{{ ubuntu_installer_version }}-{{ ubuntu_installer_variant }}-{{ ubuntu_installer_arch }}.iso$' "{{ ubuntu_installer_target_dir }}/SHA256SUMS"
    changed_when: false
    failed_when: false
    register: ubuntu_installer_old_sha256sum

  - name: set download url to old-releases.ubuntu.com
    when: (ubuntu_installer_old_sha256sum.stdout_lines | length) > 0
    set_fact:
      ubuntu_installer_base_url: "https://old-releases.ubuntu.com/releases/{{ ubuntu_installer_codename }}"

- when: ubuntu_installer_base_url is not defined
  block:
  - name: try downloading SHA256SUMS and signature file from releases.ubuntu.com
    loop:
    - SHA256SUMS
    - SHA256SUMS.gpg
    get_url:
      url: "https://releases.ubuntu.com/{{ ubuntu_installer_codename }}/{{ item }}"
      dest: "{{ ubuntu_installer_target_dir }}/{{ item }}"
      force: yes

  - name: set download url to releases.ubuntu.com
    set_fact:
      ubuntu_installer_base_url: "https://releases.ubuntu.com/{{ ubuntu_installer_codename }}"