From 093612f3a7fb3eb46ad366036b237cc48c405463 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 14 Apr 2023 10:20:16 +0200 Subject: [PATCH] Change restart-check to started/restarted check --- kubernetes/tasks/install/agent/install_k3s.yml | 5 ++--- kubernetes/tasks/install/server/install_k3s.yml | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/kubernetes/tasks/install/agent/install_k3s.yml b/kubernetes/tasks/install/agent/install_k3s.yml index e0e5728..2fd0ec6 100644 --- a/kubernetes/tasks/install/agent/install_k3s.yml +++ b/kubernetes/tasks/install/agent/install_k3s.yml @@ -6,8 +6,7 @@ retries: 2 delay: 10 -- name: Restart when config changed, but install already done +- name: Make sure service is started / restarted on config change service: name: k3s-agent - state: restarted - when: "inventory_hostname != groups['kubernetes'][0] and not command.changed and config.changed" + state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}" diff --git a/kubernetes/tasks/install/server/install_k3s.yml b/kubernetes/tasks/install/server/install_k3s.yml index 3cd0ccf..5454e48 100644 --- a/kubernetes/tasks/install/server/install_k3s.yml +++ b/kubernetes/tasks/install/server/install_k3s.yml @@ -4,11 +4,11 @@ register: command changed_when: "'No change detected' not in command.stdout" -- name: Restart when config changed, but install already done +- name: Make sure service is started / restarted on config change service: name: k3s - state: restarted - when: "inventory_hostname == groups['kubernetes'][0] and not command.changed and config.changed" + state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}" + when: "inventory_hostname == groups['kubernetes'][0]" - name: Waiting for K3s-server to accept connections ansible.builtin.wait_for: @@ -26,11 +26,11 @@ retries: 2 delay: 10 -- name: Restart when config changed, but install already done +- name: Make sure service is started / restarted on config change service: name: k3s - state: restarted - when: "inventory_hostname != groups['kubernetes'][0] and not command.changed and config.changed" + state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}" + when: "inventory_hostname != groups['kubernetes'][0]" - name: Waiting for K3s-server to accept connections on other nodes ansible.builtin.wait_for: