Skip to content

Commit cbcd1c1

Browse files
committed
chore: fix
1 parent 8b2c147 commit cbcd1c1

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

ansible/inventory/group_vars/master/k3s.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ k3s_server:
2929
disable-kube-proxy: true
3030
write-kubeconfig-mode: "644"
3131
# Network CIDR to use for pod IPs
32-
cluster-cidr: "10.42.0.0/16"
32+
cluster-cidr: "{{ cluster_cidr }}"
3333
# Network CIDR to use for service IPs
34-
service-cidr: "10.43.0.0/16"
34+
service-cidr: "{{ service_cidr }}"
3535
kube-controller-manager-arg:
3636
# Required to monitor kube-controller-manager with kube-prometheus-stack
3737
- "bind-address=0.0.0.0"

ansible/playbooks/cluster-installation.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
ansible.builtin.pause:
1111
seconds: 5
1212
tasks:
13+
- name: Check if cluster is installed
14+
ansible.builtin.stat:
15+
path: /etc/rancher/k3s/config.yaml
16+
register: k3s_check_installed
17+
check_mode: false
18+
19+
- name: Ignore manifests templates and urls if the cluster is already installed
20+
ansible.builtin.set_fact:
21+
k3s_server_manifests_templates: []
22+
k3s_server_manifests_urls: []
23+
when: k3s_check_installed.stat.exists
24+
1325
- name: Install Kubernetes
1426
ansible.builtin.include_role:
1527
name: xanmanning.k3s
@@ -104,19 +116,20 @@
104116
namespace: kube-system
105117
state: absent
106118

107-
# NOTE
108119
# Cleaning up certain manifests from the /var/lib/rancher/k3s/server/manifests directory
109120
# is needed because k3s has an awesome "feature" to always re-deploy them when the k3s
110121
# service is restarted. Removing them does not uninstall the manifests from your cluster.
111122

112-
- name: Remove deployed manifest templates
113-
ansible.builtin.file:
114-
path: "{{ k3s_server_manifests_dir }}/{{ item | basename | regex_replace('\\.j2$', '') }}"
115-
state: absent
116-
loop: "{{ k3s_server_manifests_templates | default([]) }}"
123+
- name: Get a list of all custom manifest files
124+
ansible.builtin.find:
125+
paths: "{{ k3s_server_manifests_dir }}"
126+
file_type: file
127+
use_regex: true
128+
patterns: ["^custom-.*"]
129+
register: custom_manifest
117130

118-
- name: Remove deployed manifest urls
131+
- name: Delete all custom manifest files
119132
ansible.builtin.file:
120-
path: "{{ k3s_server_manifests_dir }}/{{ item.filename }}"
133+
path: "{{ item.path }}"
121134
state: absent
122-
loop: "{{ k3s_server_manifests_urls | default([]) }}"
135+
loop: "{{ custom_manifest.files }}"

0 commit comments

Comments
 (0)