ansible-role-k3s/tasks/build/download-k3s.yml
James D. Marble 044ed5512c Use correct checksums for arm downloads
I attempted to install on arm64 and armhf. Both fail because the
[checksum filter](e07903a5cf/tasks/build/download-k3s.yml (L21))
finds the first line with "k3s". On the arm checksum files,
the first lines are for "k3s-airgap-images-arm64.tar" and "k3s-airgap-images-arm.tar"
so the wrong checksum is grabbed.

I attempted to fix this with a more specific filter:
`select('search', 'k3s'+k3s_arch_suffix)`.
This works for both arm architectures,
but fails for amd64 because the key is simply "k3s" and not "k3s-amd64".

The solution I settled on is not ideal for future proofing,
but works for now at least.
2020-01-31 21:10:55 -08:00

34 lines
1.1 KiB
YAML

---
- name: Ensure target host architecture information is set as a fact
set_fact:
k3s_arch: "{{ k3s_arch_lookup[ansible_architecture].arch }}"
k3s_arch_suffix: "{{ k3s_arch_lookup[ansible_architecture].suffix }}"
- name: Ensure URLs are set as facts for downloading binaries
set_fact:
k3s_binary_url: "{{ k3s_github_download_url }}/{{ k3s_release_version }}/k3s{{ k3s_arch_suffix }}"
k3s_hash_url: "{{ k3s_github_download_url }}/{{ k3s_release_version }}/sha256sum-{{ k3s_arch }}.txt"
- name: Ensure the k3s hashsum is downloaded
uri:
url: "{{ k3s_hash_url }}"
return_content: true
register: k3s_hash_sum_raw
- name: Ensure sha256sum is set from hashsum variable
set_fact:
k3s_hash_sum: "{{ (k3s_hash_sum_raw.content.split('\n') | reject('search', 'images') | first).split() | first }}"
changed_when: false
- name: Ensure installation directory exists
file:
path: "{{ k3s_install_dir }}"
state: directory
- name: Ensure k3s binary is downloaded
get_url:
url: "{{ k3s_binary_url }}"
dest: "{{ k3s_install_dir }}/k3s-{{ k3s_release_version }}"
checksum: "sha256:{{ k3s_hash_sum }}"
mode: 0755