summaryrefslogtreecommitdiff
path: root/roles/installer/ubuntu/fetch/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/installer/ubuntu/fetch/tasks/main.yml')
-rw-r--r--roles/installer/ubuntu/fetch/tasks/main.yml43
1 files changed, 43 insertions, 0 deletions
diff --git a/roles/installer/ubuntu/fetch/tasks/main.yml b/roles/installer/ubuntu/fetch/tasks/main.yml
new file mode 100644
index 00000000..618cfd22
--- /dev/null
+++ b/roles/installer/ubuntu/fetch/tasks/main.yml
@@ -0,0 +1,43 @@
+---
+- name: prepare directories for installer files
+ file:
+ name: "{{ ubuntu_installer_target_dir }}"
+ state: directory
+
+- include_tasks: "fetch-{{ (ubuntu_installer_version is defined) | ternary('version', 'latest') }}.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 }}?"