diff options
author | Christian Pointner <equinox@spreadspace.org> | 2022-09-02 20:48:59 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2022-09-02 20:48:59 +0200 |
commit | b4e6a203893b30e18bc647dc8961820c12c4c32b (patch) | |
tree | e5ab2f2b2f0e874a1e2b56c6b405b44f9a8c3e18 /roles/installer/ubuntu/fetch/tasks/find-location.yml | |
parent | kubernetes/emc: cosmetic change (diff) |
ubuntu/installer: improved handling of latest image
Diffstat (limited to 'roles/installer/ubuntu/fetch/tasks/find-location.yml')
-rw-r--r-- | roles/installer/ubuntu/fetch/tasks/find-location.yml | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/roles/installer/ubuntu/fetch/tasks/find-location.yml b/roles/installer/ubuntu/fetch/tasks/find-location.yml new file mode 100644 index 00000000..752eebe1 --- /dev/null +++ b/roles/installer/ubuntu/fetch/tasks/find-location.yml @@ -0,0 +1,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 }}" |