From 193ee7c4472f140bcc85da08a45b2646538291d8 Mon Sep 17 00:00:00 2001 From: NaeiKinDus Date: Mon, 29 Jul 2024 00:00:00 +0000 Subject: [PATCH] feat(k3s): allow custom Helm manifests installation --- .../infrastructure/roles/k3s/defaults/main.yml | 1 + .../infrastructure/roles/k3s/tasks/server.yml | 14 ++++++++++++++ .../infrastructure/roles/k3s/vars/main.yml | 1 + 3 files changed, 16 insertions(+) diff --git a/collections/ansible_collections/nullified/infrastructure/roles/k3s/defaults/main.yml b/collections/ansible_collections/nullified/infrastructure/roles/k3s/defaults/main.yml index 2aa199a..8c423bc 100644 --- a/collections/ansible_collections/nullified/infrastructure/roles/k3s/defaults/main.yml +++ b/collections/ansible_collections/nullified/infrastructure/roles/k3s/defaults/main.yml @@ -7,3 +7,4 @@ k3s_operator_ips: [] k3s_cluster_cidr: '10.42.0.0/16' k3s_service_cidr: '10.43.0.0/16' k3s_cluster_additional_helm_charts: [] +k3s_cluster_helm_customizations: [] diff --git a/collections/ansible_collections/nullified/infrastructure/roles/k3s/tasks/server.yml b/collections/ansible_collections/nullified/infrastructure/roles/k3s/tasks/server.yml index 76682e7..0022970 100644 --- a/collections/ansible_collections/nullified/infrastructure/roles/k3s/tasks/server.yml +++ b/collections/ansible_collections/nullified/infrastructure/roles/k3s/tasks/server.yml @@ -42,12 +42,26 @@ when: k3s_cluster_type is match("ha") failed_when: true +- name: install K3S Helm customizations + become: true + ansible.builtin.copy: + dest: "{{ k3s_manifests_dir }}/{{ item.name | regex_replace('[^\\w]', '') }}.yaml" + content: '{{ item.content }}' + mode: '0600' + owner: root + group: root + loop: '{{ k3s_cluster_helm_customizations }}' + loop_control: + label: '{{ item.name }}' + no_log: true + - name: install Helm charts connection: local kubernetes.core.helm: '{{ item }}' loop: '{{ k3s_cluster_additional_helm_charts }}' loop_control: label: '{{ item.release_name }}' + no_log: true tags: [helm] - name: install OpenTofu resources diff --git a/collections/ansible_collections/nullified/infrastructure/roles/k3s/vars/main.yml b/collections/ansible_collections/nullified/infrastructure/roles/k3s/vars/main.yml index ed97d53..b289827 100644 --- a/collections/ansible_collections/nullified/infrastructure/roles/k3s/vars/main.yml +++ b/collections/ansible_collections/nullified/infrastructure/roles/k3s/vars/main.yml @@ -1 +1,2 @@ --- +k3s_manifests_dir: '/var/lib/rancher/k3s/server/manifests'