From ef17880bfbd783e7c5182fb6234653185871c405 Mon Sep 17 00:00:00 2001 From: Peter Klijn Date: Thu, 20 Jun 2024 14:31:58 +0200 Subject: [PATCH] POC: Supporting k3s-ansible with external database Signed-off-by: Peter Klijn --- roles/k3s_server/tasks/main.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/roles/k3s_server/tasks/main.yml b/roles/k3s_server/tasks/main.yml index 0718a819e..019b21f20 100644 --- a/roles/k3s_server/tasks/main.yml +++ b/roles/k3s_server/tasks/main.yml @@ -58,7 +58,7 @@ when: inventory_hostname == groups[server_group][0] block: - name: Copy K3s service file [Single] - when: groups[server_group] | length == 1 + when: groups[server_group] | length == 1 or use_external_database | default(false) | bool ansible.builtin.template: src: "k3s-single.service.j2" dest: "{{ systemd_dir }}/k3s.service" @@ -148,7 +148,9 @@ - inventory_hostname != groups[server_group][0] block: - name: Copy K3s service file [HA] - when: groups[server_group] | length > 1 + when: + - groups[server_group] | length > 1 + - use_external_database | default(false) | bool == false ansible.builtin.template: src: "k3s-ha.service.j2" dest: "{{ systemd_dir }}/k3s.service" @@ -156,6 +158,17 @@ group: root mode: "0644" + - name: Copy K3s service file [External DB] + when: + - groups[server_group] | length > 1 + - use_external_database | default(false) | bool + ansible.builtin.template: + src: "k3s-single.service.j2" + dest: "{{ systemd_dir }}/k3s.service" + owner: root + group: root + mode: "0644" + - name: Enable and check K3s service ansible.builtin.systemd: name: k3s