ansible-role-k3s/tasks/build/download-k3s.yml

39 lines
1.3 KiB
YAML
Raw Normal View History

2019-03-09 21:54:44 +01:00
---
- 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
2019-12-11 14:17:05 +01:00
set_fact:
k3s_hash_sum: "{{ (k3s_hash_sum_raw.content.split('\n') |
select('search', 'k3s' + k3s_arch_suffix) |
reject('search', 'images') |
first).split() | first }}"
2019-03-09 21:54:44 +01:00
changed_when: false
- name: Ensure installation directory exists
file:
path: "{{ k3s_install_dir }}"
state: directory
2019-03-09 21:54:44 +01:00
- name: Ensure k3s binary is downloaded
get_url:
url: "{{ k3s_binary_url }}"
dest: "{{ k3s_install_dir }}/k3s-{{ k3s_release_version }}"
2019-12-11 14:17:05 +01:00
checksum: "sha256:{{ k3s_hash_sum }}"
2019-03-09 21:54:44 +01:00
mode: 0755
become: "{{ k3s_become_for_install_dir | ternary(true, false, k3s_become_for_all) }}"