From d6f8f975bb868b09ef9d8dc4dd75b36abdea1fc7 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Wed, 5 Apr 2023 13:32:14 +0200 Subject: [PATCH] Reload when config changed, but install already done --- kubernetes/tasks/install/agent/install_k3s.yml | 7 ++++++- kubernetes/tasks/install/server/install_k3s.yml | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 }}"