feat: always delete custom- prefixed files from k3s_server_manifests_dir
Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
2 files changed
+33
-47
No files matched your search
@@ -34,27 +34,13 @@ k3s_server_manifests_urls:
|
|||||||
# Tigera Operator
|
# Tigera Operator
|
||||||
- url: https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml
|
- url: https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml
|
||||||
filename: custom-calico-tigera-operator.yaml
|
filename: custom-calico-tigera-operator.yaml
|
||||||
# Prometheus Operator
|
# Essential Prometheus Operator CRDs
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml
|
|
||||||
filename: custom-prometheus-alertmanagerconfigs.yaml
|
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml
|
|
||||||
filename: custom-prometheus-alertmanagers.yaml
|
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
|
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
|
||||||
filename: custom-prometheus-podmonitors.yaml
|
filename: custom-prometheus-podmonitors.yaml
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml
|
|
||||||
filename: custom-prometheus-probes.yaml
|
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml
|
|
||||||
filename: custom-prometheus-prometheuses.yaml
|
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
|
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
|
||||||
filename: custom-prometheus-prometheusrules.yaml
|
filename: custom-prometheus-prometheusrules.yaml
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
|
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
|
||||||
filename: custom-prometheus-servicemonitors.yaml
|
filename: custom-prometheus-servicemonitors.yaml
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml
|
|
||||||
filename: custom-prometheus-thanosrulers.yaml
|
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml
|
|
||||||
filename: custom-prometheus-scrapeconfigs.yaml
|
|
||||||
- url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.65.1/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml
|
|
||||||
filename: custom-prometheus-prometheusagents.yaml
|
|
||||||
|
|
||||||
# (list) A flat list of templates to deploy on the primary control plane
|
# (list) A flat list of templates to deploy on the primary control plane
|
||||||
# /var/lib/rancher/k3s/server/manifests
|
# /var/lib/rancher/k3s/server/manifests
|
||||||
|
|||||||
@@ -10,6 +10,18 @@
|
|||||||
ansible.builtin.pause:
|
ansible.builtin.pause:
|
||||||
seconds: 5
|
seconds: 5
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Check if cluster is installed
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/rancher/k3s/config.yaml
|
||||||
|
register: k3s_check_installed
|
||||||
|
check_mode: false
|
||||||
|
|
||||||
|
- name: Ignore manifests templates and urls if the cluster is already installed
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
k3s_server_manifests_templates: []
|
||||||
|
k3s_server_manifests_urls: []
|
||||||
|
when: k3s_check_installed.stat.exists
|
||||||
|
|
||||||
- name: Install Kubernetes
|
- name: Install Kubernetes
|
||||||
ansible.builtin.include_role:
|
ansible.builtin.include_role:
|
||||||
name: xanmanning.k3s
|
name: xanmanning.k3s
|
||||||
@@ -56,34 +68,20 @@
|
|||||||
wait_sleep: 10
|
wait_sleep: 10
|
||||||
wait_timeout: 360
|
wait_timeout: 360
|
||||||
loop:
|
loop:
|
||||||
- kind: Deployment
|
- name: tigera-operator
|
||||||
name: tigera-operator
|
kind: Deployment
|
||||||
namespace: tigera-operator
|
namespace: tigera-operator
|
||||||
- kind: DaemonSet
|
- name: kube-vip
|
||||||
name: kube-vip
|
kind: DaemonSet
|
||||||
namespace: kube-system
|
namespace: kube-system
|
||||||
- kind: Installation
|
- kind: Installation
|
||||||
name: default
|
name: default
|
||||||
- kind: CustomResourceDefinition
|
- name: podmonitors.monitoring.coreos.com
|
||||||
name: alertmanagerconfigs.monitoring.coreos.com
|
kind: CustomResourceDefinition
|
||||||
- kind: CustomResourceDefinition
|
- name: prometheusrules.monitoring.coreos.com
|
||||||
name: alertmanagers.monitoring.coreos.com
|
kind: CustomResourceDefinition
|
||||||
- kind: CustomResourceDefinition
|
- name: servicemonitors.monitoring.coreos.com
|
||||||
name: podmonitors.monitoring.coreos.com
|
kind: CustomResourceDefinition
|
||||||
- kind: CustomResourceDefinition
|
|
||||||
name: probes.monitoring.coreos.com
|
|
||||||
- kind: CustomResourceDefinition
|
|
||||||
name: prometheuses.monitoring.coreos.com
|
|
||||||
- kind: CustomResourceDefinition
|
|
||||||
name: prometheusrules.monitoring.coreos.com
|
|
||||||
- kind: CustomResourceDefinition
|
|
||||||
name: servicemonitors.monitoring.coreos.com
|
|
||||||
- kind: CustomResourceDefinition
|
|
||||||
name: thanosrulers.monitoring.coreos.com
|
|
||||||
- kind: CustomResourceDefinition
|
|
||||||
name: scrapeconfigs.monitoring.coreos.com
|
|
||||||
- kind: CustomResourceDefinition
|
|
||||||
name: prometheusagents.monitoring.coreos.com
|
|
||||||
when:
|
when:
|
||||||
- k3s_server_manifests_templates | length > 0
|
- k3s_server_manifests_templates | length > 0
|
||||||
or k3s_server_manifests_urls | length > 0
|
or k3s_server_manifests_urls | length > 0
|
||||||
@@ -95,14 +93,16 @@
|
|||||||
# is needed because k3s has an awesome "feature" to always re-deploy them when the k3s
|
# is needed because k3s has an awesome "feature" to always re-deploy them when the k3s
|
||||||
# service is restarted. Removing them does not uninstall the manifests from your cluster.
|
# service is restarted. Removing them does not uninstall the manifests from your cluster.
|
||||||
|
|
||||||
- name: Remove deployed manifest templates
|
- name: Get a list of all custom manifest files
|
||||||
ansible.builtin.file:
|
ansible.builtin.find:
|
||||||
path: "{{ k3s_server_manifests_dir }}/{{ item | basename | regex_replace('\\.j2$', '') }}"
|
paths: "{{ k3s_server_manifests_dir }}"
|
||||||
state: absent
|
file_type: file
|
||||||
loop: "{{ k3s_server_manifests_templates | default([]) }}"
|
use_regex: true
|
||||||
|
patterns: ["^custom-.*"]
|
||||||
|
register: custom_manifest_files
|
||||||
|
|
||||||
- name: Remove deployed manifest urls
|
- name: Delete all custom manifest files
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ k3s_server_manifests_dir }}/{{ item.filename }}"
|
path: "{{ item.path }}"
|
||||||
state: absent
|
state: absent
|
||||||
loop: "{{ k3s_server_manifests_urls | default([]) }}"
|
loop: "{{ custom_manifest_files }}"
|
||||||
Reference in new issue
Block a user