mirror of
https://github.com/PyratLabs/ansible-role-k3s
synced 2024-12-13 14:30:17 +01:00
Merge pull request #28 from pedrohdz/control-node-restart-k3s
Restart k3s service unit on file change
This commit is contained in:
commit
f454334b42
2 changed files with 14 additions and 4 deletions
|
@ -16,7 +16,7 @@
|
||||||
- name: Ensure k3s service unit file is present
|
- name: Ensure k3s service unit file is present
|
||||||
template:
|
template:
|
||||||
src: k3s.service.j2
|
src: k3s.service.j2
|
||||||
dest: /etc/systemd/system/k3s.service
|
dest: "{{ k3s_systemd_unit_directory }}/k3s.service"
|
||||||
become: "{{ k3s_become_for_systemd | ternary(true, false, k3s_become_for_all) }}"
|
become: "{{ k3s_become_for_systemd | ternary(true, false, k3s_become_for_all) }}"
|
||||||
notify:
|
notify:
|
||||||
- reload systemd
|
- reload systemd
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
|
- name: Ensure k3s is symlinked into the installation destination on the contol plane
|
||||||
|
file:
|
||||||
|
src: "{{ k3s_install_dir }}/k3s-{{ k3s_release_version }}"
|
||||||
|
dest: "{{ k3s_install_dir }}/k3s"
|
||||||
|
state: link
|
||||||
|
when: (k3s_control_node and k3s_controller_count | length == 1)
|
||||||
|
or (k3s_primary_control_node and k3s_controller_count | length > 1)
|
||||||
|
notify:
|
||||||
|
- restart k3s
|
||||||
|
become: "{{ k3s_become_for_install_dir | ternary(true, false, k3s_become_for_all) }}"
|
||||||
|
|
||||||
- name: Ensure systemd unit file directory exists
|
- name: Ensure systemd unit file directory exists
|
||||||
file:
|
file:
|
||||||
path: "{{ k3s_systemd_unit_directory }}"
|
path: "{{ k3s_systemd_unit_directory }}"
|
||||||
state: directory
|
state: directory
|
||||||
recurse: true
|
recurse: true
|
||||||
when: (k3s_control_node and k3s_controller_count | length == 1)
|
|
||||||
or (k3s_primary_control_node and k3s_controller_count | length > 1)
|
|
||||||
|
|
||||||
- name: Ensure k3s service unit file is present on control plane
|
- name: Ensure k3s service unit file is present on control plane
|
||||||
template:
|
template:
|
||||||
|
@ -16,6 +25,7 @@
|
||||||
or (k3s_primary_control_node and k3s_controller_count | length > 1)
|
or (k3s_primary_control_node and k3s_controller_count | length > 1)
|
||||||
notify:
|
notify:
|
||||||
- reload systemd
|
- reload systemd
|
||||||
|
- restart k3s
|
||||||
become: "{{ k3s_become_for_systemd | ternary(true, false, k3s_become_for_all) }}"
|
become: "{{ k3s_become_for_systemd | ternary(true, false, k3s_become_for_all) }}"
|
||||||
|
|
||||||
- meta: flush_handlers
|
- meta: flush_handlers
|
||||||
|
@ -34,7 +44,7 @@
|
||||||
mode: 0700
|
mode: 0700
|
||||||
become: "{{ k3s_become_for_usr_local_bin | ternary(true, false, k3s_become_for_all) }}"
|
become: "{{ k3s_become_for_usr_local_bin | ternary(true, false, k3s_become_for_all) }}"
|
||||||
|
|
||||||
- name: Ensure k3s is symlinked into the installation destinations
|
- name: Ensure k3s is symlinked into the installation destinations across all nodes
|
||||||
file:
|
file:
|
||||||
src: "{{ k3s_install_dir }}/k3s-{{ k3s_release_version }}"
|
src: "{{ k3s_install_dir }}/k3s-{{ k3s_release_version }}"
|
||||||
dest: "{{ k3s_install_dir }}/{{ item }}"
|
dest: "{{ k3s_install_dir }}/{{ item }}"
|
||||||
|
|
Loading…
Reference in a new issue