mirror of
https://github.com/PyratLabs/ansible-role-k3s.git
synced 2024-11-29 12:55:51 +01:00
Build-operate workflow trial - allow for stop-starting cluster.
This commit is contained in:
parent
e8e5dbf45a
commit
717de81c7f
@ -45,6 +45,7 @@ consistency.
|
||||
|
||||
| Variable | Description | Default Value |
|
||||
|--------------------------------|--------------------------------------------------------------------------|--------------------------------|
|
||||
| `k3s_cluster_state` | State of cluster, options: installed, started, stopped, restarted. | installed |
|
||||
| `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_install_dir` | Installation directory for k3s. | `/usr/local/bin` |
|
||||
|
@ -1,5 +1,9 @@
|
||||
---
|
||||
|
||||
# k3s cluster state, options: installed, started, stopped, restarted
|
||||
# (default: installed)
|
||||
k3s_cluster_state: installed
|
||||
|
||||
# Use a specific k3s version, if set to "false" we will get the latest
|
||||
# k3s_release_version: v0.1.0
|
||||
k3s_release_version: false
|
||||
|
9
molecule/default/playbook-restart-cluster.yml
Normal file
9
molecule/default/playbook-restart-cluster.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
molecule_is_test: true
|
||||
k3s_cluster_state: restarted
|
||||
roles:
|
||||
- role: xanmanning.k3s
|
9
molecule/default/playbook-start-cluster.yml
Normal file
9
molecule/default/playbook-start-cluster.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
molecule_is_test: true
|
||||
k3s_cluster_state: started
|
||||
roles:
|
||||
- role: xanmanning.k3s
|
9
molecule/default/playbook-stop-cluster.yml
Normal file
9
molecule/default/playbook-stop-cluster.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
molecule_is_test: true
|
||||
k3s_cluster_state: stopped
|
||||
roles:
|
||||
- role: xanmanning.k3s
|
@ -1,27 +1,11 @@
|
||||
---
|
||||
|
||||
- import_tasks: preconfigure-k3s.yml
|
||||
- name: Check to see if k3s_cluster_state is a supported value
|
||||
assert:
|
||||
that:
|
||||
- k3s_cluster_state in ['installed', 'started', 'stopped', 'restarted']
|
||||
fail_msg: "k3s_cluster_state not valid. Check README.md for details."
|
||||
success_msg: "k3s_cluster_state is valid."
|
||||
when: k3s_cluster_state is defined
|
||||
|
||||
- include_tasks: install-docker-prerequisites-{{ ansible_os_family | lower }}.yml
|
||||
when: k3s_use_docker
|
||||
and ((k3s_control_workers)
|
||||
or (not k3s_control_workers and not k3s_control_node))
|
||||
|
||||
- import_tasks: install-docker.yml
|
||||
when: k3s_use_docker
|
||||
and ((k3s_control_workers)
|
||||
or (not k3s_control_workers and not k3s_control_node))
|
||||
and ansible_distribution | replace(" ", "-") | lower not in ['amazon', 'suse', 'opensuse-leap']
|
||||
|
||||
- include_tasks: install-docker-{{ ansible_distribution | replace(" ", "-") | lower }}.yml
|
||||
when: ansible_distribution | replace(" ", "-") | lower in ['amazon', 'suse', 'opensuse-leap']
|
||||
|
||||
- import_tasks: get-version.yml
|
||||
when: k3s_release_version is not defined or not k3s_release_version
|
||||
|
||||
- import_tasks: download-k3s.yml
|
||||
|
||||
- import_tasks: install-k3s.yml
|
||||
|
||||
- import_tasks: configure-k3s-cluster.yml
|
||||
when: play_hosts | length > 1
|
||||
- import_tasks: state-{{ (k3s_cluster_state | lower) | default('installed') }}.yml
|
||||
|
7
tasks/operate/start-k3s.yml
Normal file
7
tasks/operate/start-k3s.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Ensure k3s service is started
|
||||
service:
|
||||
name: k3s
|
||||
state: started
|
||||
enabled: true
|
7
tasks/operate/stop-k3s.yml
Normal file
7
tasks/operate/stop-k3s.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Ensure k3s service is stopped
|
||||
service:
|
||||
name: k3s
|
||||
state: stopped
|
||||
enabled: false
|
27
tasks/state-installed.yml
Normal file
27
tasks/state-installed.yml
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
|
||||
- import_tasks: preconfigure-k3s.yml
|
||||
|
||||
- include_tasks: build/install-docker-prerequisites-{{ ansible_os_family | lower }}.yml
|
||||
when: k3s_use_docker
|
||||
and ((k3s_control_workers)
|
||||
or (not k3s_control_workers and not k3s_control_node))
|
||||
|
||||
- import_tasks: build/install-docker.yml
|
||||
when: k3s_use_docker
|
||||
and ((k3s_control_workers)
|
||||
or (not k3s_control_workers and not k3s_control_node))
|
||||
and ansible_distribution | replace(" ", "-") | lower not in ['amazon', 'suse', 'opensuse-leap']
|
||||
|
||||
- include_tasks: build/install-docker-{{ ansible_distribution | replace(" ", "-") | lower }}.yml
|
||||
when: ansible_distribution | replace(" ", "-") | lower in ['amazon', 'suse', 'opensuse-leap']
|
||||
|
||||
- import_tasks: build/get-version.yml
|
||||
when: k3s_release_version is not defined or not k3s_release_version
|
||||
|
||||
- import_tasks: build/download-k3s.yml
|
||||
|
||||
- import_tasks: build/install-k3s.yml
|
||||
|
||||
- import_tasks: build/configure-k3s-cluster.yml
|
||||
when: play_hosts | length > 1
|
4
tasks/state-restarted.yml
Normal file
4
tasks/state-restarted.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
|
||||
- import_tasks: operate/stop-k3s.yml
|
||||
- import_tasks: operate/start-k3s.yml
|
3
tasks/state-started.yml
Normal file
3
tasks/state-started.yml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
|
||||
- import_tasks: operate/start-k3s.yml
|
3
tasks/state-stopped.yml
Normal file
3
tasks/state-stopped.yml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
|
||||
- import_tasks: operate/stop-k3s.yml
|
Loading…
Reference in New Issue
Block a user