2019-03-09 21:54:44 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Ensure target host architecture information is set as a fact
|
2020-12-21 20:14:52 +01:00
|
|
|
ansible.builtin.set_fact:
|
2019-03-09 21:54:44 +01:00
|
|
|
k3s_arch: "{{ k3s_arch_lookup[ansible_architecture].arch }}"
|
|
|
|
k3s_arch_suffix: "{{ k3s_arch_lookup[ansible_architecture].suffix }}"
|
2020-07-25 18:39:01 +02:00
|
|
|
check_mode: false
|
2019-03-09 21:54:44 +01:00
|
|
|
|
|
|
|
- name: Ensure URLs are set as facts for downloading binaries
|
2020-12-21 20:14:52 +01:00
|
|
|
ansible.builtin.set_fact:
|
2019-03-09 21:54:44 +01:00
|
|
|
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"
|
2020-07-25 18:39:01 +02:00
|
|
|
check_mode: false
|
2019-03-09 21:54:44 +01:00
|
|
|
|
2020-09-23 15:43:31 +02:00
|
|
|
- name: Override k3s_binary_url and k3s_hash_url facts for testing specific commit
|
2020-12-21 20:14:52 +01:00
|
|
|
ansible.builtin.set_fact:
|
2020-09-23 15:43:31 +02:00
|
|
|
k3s_binary_url: "https://storage.googleapis.com/k3s-ci-builds/k3s{{ k3s_arch_suffix }}-{{ k3s_release_version }}"
|
|
|
|
k3s_hash_url: "https://storage.googleapis.com/k3s-ci-builds/k3s{{ k3s_arch_suffix }}-{{ k3s_release_version }}.sha256sum"
|
|
|
|
when:
|
|
|
|
- k3s_release_version | regex_search("^[a-z0-9]{40}$")
|
|
|
|
check_mode: false
|
|
|
|
|
2019-03-09 21:54:44 +01:00
|
|
|
- name: Ensure the k3s hashsum is downloaded
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.uri:
|
2019-03-09 21:54:44 +01:00
|
|
|
url: "{{ k3s_hash_url }}"
|
|
|
|
return_content: true
|
|
|
|
register: k3s_hash_sum_raw
|
2020-07-25 18:39:01 +02:00
|
|
|
check_mode: false
|
2019-03-09 21:54:44 +01:00
|
|
|
|
|
|
|
- name: Ensure sha256sum is set from hashsum variable
|
2020-12-21 20:14:52 +01:00
|
|
|
ansible.builtin.set_fact:
|
2020-02-09 16:00:59 +01:00
|
|
|
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
|
2020-07-25 18:39:01 +02:00
|
|
|
check_mode: false
|
2019-03-09 21:54:44 +01:00
|
|
|
|
2019-12-21 18:11:30 +01:00
|
|
|
- name: Ensure installation directory exists
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.file:
|
2019-12-21 18:11:30 +01:00
|
|
|
path: "{{ k3s_install_dir }}"
|
|
|
|
state: directory
|
2020-09-15 19:10:25 +02:00
|
|
|
mode: 0755
|
2019-12-21 18:11:30 +01:00
|
|
|
|
2019-03-09 21:54:44 +01:00
|
|
|
- name: Ensure k3s binary is downloaded
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.get_url:
|
2019-03-09 21:54:44 +01:00
|
|
|
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
|
2022-01-02 22:52:09 +01:00
|
|
|
become: "{{ k3s_become }}"
|