mirror of
https://github.com/PyratLabs/ansible-role-k3s.git
synced 2024-11-26 12:27:28 +01:00
Added new state "downloaded" - improved getting latest version
This commit is contained in:
parent
f2a3f75f08
commit
da427f1518
@ -45,7 +45,7 @@ consistency.
|
|||||||
|
|
||||||
| Variable | Description | Default Value |
|
| Variable | Description | Default Value |
|
||||||
|--------------------------------|--------------------------------------------------------------------------|--------------------------------|
|
|--------------------------------|--------------------------------------------------------------------------|--------------------------------|
|
||||||
| `k3s_cluster_state` | State of cluster, options: installed, started, stopped, restarted. | installed |
|
| `k3s_cluster_state` | State of cluster: installed, started, stopped, restarted, downloaded. | installed |
|
||||||
| `k3s_release_version` | Use a specific version of k3s, eg. `v0.2.0`. Specify `false` for latest. | `false` |
|
| `k3s_release_version` | Use a specific version of k3s, eg. `v0.2.0`. Specify `false` for latest. | `false` |
|
||||||
| `k3s_github_url` | Set the GitHub URL to install k3s from. | https://github.com/rancher/k3s |
|
| `k3s_github_url` | Set the GitHub URL to install k3s from. | https://github.com/rancher/k3s |
|
||||||
| `k3s_install_dir` | Installation directory for k3s. | `/usr/local/bin` |
|
| `k3s_install_dir` | Installation directory for k3s. | `/usr/local/bin` |
|
||||||
|
9
molecule/default/playbook-download.yml
Normal file
9
molecule/default/playbook-download.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
vars:
|
||||||
|
molecule_is_test: true
|
||||||
|
k3s_cluster_state: downloaded
|
||||||
|
roles:
|
||||||
|
- role: xanmanning.k3s
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
- name: Get the latest release version from GitHub
|
- name: Get the latest release version from GitHub
|
||||||
uri:
|
uri:
|
||||||
url: https://github.com/rancher/k3s/releases/latest
|
url: "{{ k3s_github_api_releases }}"
|
||||||
|
return_content: true
|
||||||
|
body_format: json
|
||||||
register: k3s_latest_release
|
register: k3s_latest_release
|
||||||
|
|
||||||
- name: Ensure the release version is set as a fact
|
- name: Ensure the release version is set as a fact
|
||||||
set_fact:
|
set_fact:
|
||||||
k3s_release_version: "{{ k3s_latest_release.url.split('/')[-1] }}"
|
k3s_release_version: "{{ k3s_latest_release.json.tag_name }}"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
- name: Check to see if k3s_cluster_state is a supported value
|
- name: Check to see if k3s_cluster_state is a supported value
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- k3s_cluster_state in ['installed', 'started', 'stopped', 'restarted']
|
- k3s_cluster_state in ['installed', 'started', 'stopped', 'restarted', 'downloaded']
|
||||||
fail_msg: "k3s_cluster_state not valid. Check README.md for details."
|
fail_msg: "k3s_cluster_state not valid. Check README.md for details."
|
||||||
success_msg: "k3s_cluster_state is valid."
|
success_msg: "k3s_cluster_state is valid."
|
||||||
when: k3s_cluster_state is defined
|
when: k3s_cluster_state is defined
|
||||||
|
6
tasks/state-downloaded.yml
Normal file
6
tasks/state-downloaded.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- import_tasks: build/get-version.yml
|
||||||
|
when: k3s_release_version is not defined or not k3s_release_version
|
||||||
|
|
||||||
|
- import_tasks: build/download-k3s.yml
|
@ -26,6 +26,8 @@ k3s_arch_lookup:
|
|||||||
arch: arm
|
arch: arm
|
||||||
suffix: "-armhf"
|
suffix: "-armhf"
|
||||||
|
|
||||||
|
k3s_github_api: "{{ k3s_github_url | replace('github.com', 'api.github.com') }}"
|
||||||
|
k3s_github_api_releases: "{{ k3s_github_api | replace('.com', '.com/repos') }}/releases/latest"
|
||||||
k3s_github_download_url: "{{ k3s_github_url }}/releases/download"
|
k3s_github_download_url: "{{ k3s_github_url }}/releases/download"
|
||||||
k3s_controller_count: []
|
k3s_controller_count: []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user