diff --git a/kubernetes/tasks/install/agent/install_k3s.yml b/kubernetes/tasks/install/agent/install_k3s.yml index b465095..10f7ce3 100644 --- a/kubernetes/tasks/install/agent/install_k3s.yml +++ b/kubernetes/tasks/install/agent/install_k3s.yml @@ -1,7 +1,12 @@ - name: Install K3s agent - command: /root/k3s_install.sh {{ type }} + command: /root/k3s_install.sh {{ type }} register: command changed_when: "'No change detected' in command.stdout" until: "command is not failed" retries: 2 delay: 10 + +- name: Restart when config changed, but install already done + service: k3s + status: restarted + when: "inventory_hostname != groups['kubernetes'][0] && !command.changed && config.changed" diff --git a/kubernetes/tasks/install/server/install_k3s.yml b/kubernetes/tasks/install/server/install_k3s.yml index 262fb93..f5a34e5 100644 --- a/kubernetes/tasks/install/server/install_k3s.yml +++ b/kubernetes/tasks/install/server/install_k3s.yml @@ -4,6 +4,11 @@ register: command changed_when: "'No change detected' in command.stdout" +- name: Restart when config changed, but install already done + service: k3s + status: restarted + when: "inventory_hostname == groups['kubernetes'][0] && !command.changed && config.changed" + - name: Waiting for K3s-server to accept connections ansible.builtin.wait_for: host: "{{ inventory_hostname }}" @@ -20,6 +25,11 @@ retries: 2 delay: 10 +- name: Restart when config changed, but install already done + service: k3s + status: restarted + when: "inventory_hostname != groups['kubernetes'][0] && !command.changed && config.changed" + - name: Waiting for K3s-server to accept connections on other nodes ansible.builtin.wait_for: host: "{{ inventory_hostname }}"