From 0c4f0260d5ec6da04dc06bdcb96a004d46fb5801 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Thu, 18 Jan 2024 13:52:11 -0500 Subject: [PATCH] fix: ansible dir should only exist for k3s and k0s (#1191) * fix: ansible dir should only exist for k3s and k0s Signed-off-by: Devin Buhl * fix: rename partial files Signed-off-by: Devin Buhl --------- Signed-off-by: Devin Buhl --- bootstrap/templates/ansible/.ansible-lint.j2 | 2 ++ .../inventory/group_vars/kubernetes/supplemental.yaml.j2 | 2 ++ bootstrap/templates/ansible/inventory/hosts.yaml.j2 | 2 ++ bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2 | 6 ++---- .../templates/ansible/playbooks/cluster-prepare.yaml.j2 | 2 ++ .../templates/ansible/playbooks/cluster-reboot.yaml.j2 | 2 ++ .../ansible/playbooks/cluster-rollout-update.yaml.j2 | 2 ++ .../playbooks/templates/custom-cilium-helmchart.yaml.j2.j2 | 2 +- .../apps/kube-system/cilium/app/helmrelease.yaml.j2 | 2 +- bootstrap/templates/kubernetes/k0s/k0sctl.yaml.j2 | 2 +- ...full.yaml.partial => cilium-values-full.partial.yaml.j2} | 0 ...init.yaml.partial => cilium-values-init.partial.yaml.j2} | 0 makejinja.toml | 2 +- 13 files changed, 18 insertions(+), 8 deletions(-) rename bootstrap/templates/partials/{cilium-values-full.yaml.partial => cilium-values-full.partial.yaml.j2} (100%) rename bootstrap/templates/partials/{cilium-values-init.yaml.partial => cilium-values-init.partial.yaml.j2} (100%) diff --git a/bootstrap/templates/ansible/.ansible-lint.j2 b/bootstrap/templates/ansible/.ansible-lint.j2 index 36f6b441462..9608493a6ed 100644 --- a/bootstrap/templates/ansible/.ansible-lint.j2 +++ b/bootstrap/templates/ansible/.ansible-lint.j2 @@ -1,3 +1,4 @@ +#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %# skip_list: - yaml[commas] - yaml[line-length] @@ -7,3 +8,4 @@ warn_list: - deprecated-command-syntax - experimental - no-changed-when +#% endif %# diff --git a/bootstrap/templates/ansible/inventory/group_vars/kubernetes/supplemental.yaml.j2 b/bootstrap/templates/ansible/inventory/group_vars/kubernetes/supplemental.yaml.j2 index fcb7ad05f9f..ee6ae82e76a 100644 --- a/bootstrap/templates/ansible/inventory/group_vars/kubernetes/supplemental.yaml.j2 +++ b/bootstrap/templates/ansible/inventory/group_vars/kubernetes/supplemental.yaml.j2 @@ -1,3 +1,4 @@ +#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %# --- timezone: "#{ bootstrap_timezone }#" github_username: "#{ bootstrap_github_username }#" @@ -17,3 +18,4 @@ node_cidr: "#{ bootstrap_node_cidr }#" cluster_cidr_v6: "#{ bootstrap_cluster_cidr.split(',')[1] }#" service_cidr_v6: "#{ bootstrap_service_cidr.split(',')[1] }#" #% endif %# +#% endif %# diff --git a/bootstrap/templates/ansible/inventory/hosts.yaml.j2 b/bootstrap/templates/ansible/inventory/hosts.yaml.j2 index 695d07b948a..9302adcc8e1 100644 --- a/bootstrap/templates/ansible/inventory/hosts.yaml.j2 +++ b/bootstrap/templates/ansible/inventory/hosts.yaml.j2 @@ -1,3 +1,4 @@ +#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %# --- kubernetes: children: @@ -25,3 +26,4 @@ kubernetes: #% endif %# #% endfor %# #% endif %# +#% endif %# diff --git a/bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2 b/bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2 index e9b93bc350f..ca86af2515d 100644 --- a/bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2 +++ b/bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2 @@ -1,3 +1,4 @@ +#% if bootstrap_distribution == 'k3s' %# --- - name: Cluster Nuke hosts: kubernetes @@ -21,7 +22,6 @@ ansible.builtin.pause: seconds: 5 tasks: - #% if bootstrap_distribution == "k3s" %# - name: Stop Kubernetes # noqa: ignore-errors ignore_errors: true block: @@ -31,7 +31,6 @@ public: true vars: k3s_state: stopped - #% endif %# # https://github.com/k3s-io/docs/blob/main/docs/installation/network-options.md - name: Networking @@ -57,7 +56,6 @@ path: /etc/cni/net.d state: absent - #% if bootstrap_distribution == "k3s" %# - name: Check to see if k3s-killall.sh exits ansible.builtin.stat: path: /usr/local/bin/k3s-killall.sh @@ -92,7 +90,6 @@ path: "{{ k3s_install_dir }}/{{ item }}" state: absent loop: ["kubectl", "crictl", "ctr"] - #% endif %# - name: Remove local storage path ansible.builtin.file: @@ -103,3 +100,4 @@ ansible.builtin.reboot: msg: Rebooting nodes reboot_timeout: 3600 +#% endif %# diff --git a/bootstrap/templates/ansible/playbooks/cluster-prepare.yaml.j2 b/bootstrap/templates/ansible/playbooks/cluster-prepare.yaml.j2 index a076d696139..3767b5d17dd 100644 --- a/bootstrap/templates/ansible/playbooks/cluster-prepare.yaml.j2 +++ b/bootstrap/templates/ansible/playbooks/cluster-prepare.yaml.j2 @@ -1,3 +1,4 @@ +#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %# --- - name: Prepare System hosts: kubernetes @@ -130,3 +131,4 @@ ansible.builtin.reboot: msg: Rebooting nodes reboot_timeout: 3600 +#% endif %# diff --git a/bootstrap/templates/ansible/playbooks/cluster-reboot.yaml.j2 b/bootstrap/templates/ansible/playbooks/cluster-reboot.yaml.j2 index 07ae62a8e89..8c73e49cf76 100644 --- a/bootstrap/templates/ansible/playbooks/cluster-reboot.yaml.j2 +++ b/bootstrap/templates/ansible/playbooks/cluster-reboot.yaml.j2 @@ -1,3 +1,4 @@ +#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %# --- - name: Reboot hosts: kubernetes @@ -13,3 +14,4 @@ ansible.builtin.reboot: msg: Rebooting nodes reboot_timeout: 3600 +#% endif %# diff --git a/bootstrap/templates/ansible/playbooks/cluster-rollout-update.yaml.j2 b/bootstrap/templates/ansible/playbooks/cluster-rollout-update.yaml.j2 index 86a0b9b0fc5..e29c145530b 100644 --- a/bootstrap/templates/ansible/playbooks/cluster-rollout-update.yaml.j2 +++ b/bootstrap/templates/ansible/playbooks/cluster-rollout-update.yaml.j2 @@ -1,3 +1,4 @@ +#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %# --- # https://github.com/kevincoakley/ansible-role-k8s-rolling-update - name: Cluster rollout update @@ -86,3 +87,4 @@ #% endif %# state: uncordon delegate_to: "{{ groups['master'][0] }}" +#% endif %# diff --git a/bootstrap/templates/ansible/playbooks/templates/custom-cilium-helmchart.yaml.j2.j2 b/bootstrap/templates/ansible/playbooks/templates/custom-cilium-helmchart.yaml.j2.j2 index b81c0cca20c..e17eeef651a 100644 --- a/bootstrap/templates/ansible/playbooks/templates/custom-cilium-helmchart.yaml.j2.j2 +++ b/bootstrap/templates/ansible/playbooks/templates/custom-cilium-helmchart.yaml.j2.j2 @@ -15,6 +15,6 @@ spec: bootstrap: true valuesContent: |- #% filter indent(width=4, first=True) %# - #% include 'partials/cilium-values-init.yaml.partial' %# + #% include 'partials/cilium-values-init.partial.yaml.j2' %# #% endfilter %# #% endif %# diff --git a/bootstrap/templates/kubernetes/apps/kube-system/cilium/app/helmrelease.yaml.j2 b/bootstrap/templates/kubernetes/apps/kube-system/cilium/app/helmrelease.yaml.j2 index e4c2d68ace6..22695e80994 100644 --- a/bootstrap/templates/kubernetes/apps/kube-system/cilium/app/helmrelease.yaml.j2 +++ b/bootstrap/templates/kubernetes/apps/kube-system/cilium/app/helmrelease.yaml.j2 @@ -25,5 +25,5 @@ spec: keepHistory: false values: #% filter indent(width=4, first=True) %# - #% include 'partials/cilium-values-full.yaml.partial' %# + #% include 'partials/cilium-values-full.partial.yaml.j2' %# #% endfilter %# diff --git a/bootstrap/templates/kubernetes/k0s/k0sctl.yaml.j2 b/bootstrap/templates/kubernetes/k0s/k0sctl.yaml.j2 index e0d4353c8f0..1e95b70b41a 100644 --- a/bootstrap/templates/kubernetes/k0s/k0sctl.yaml.j2 +++ b/bootstrap/templates/kubernetes/k0s/k0sctl.yaml.j2 @@ -121,6 +121,6 @@ spec: namespace: kube-system values: |2 #% filter indent(width=18, first=True) %# - #% include 'partials/cilium-values-init.yaml.partial' %# + #% include 'partials/cilium-values-init.partial.yaml.j2' %# #% endfilter %# #% endif %# diff --git a/bootstrap/templates/partials/cilium-values-full.yaml.partial b/bootstrap/templates/partials/cilium-values-full.partial.yaml.j2 similarity index 100% rename from bootstrap/templates/partials/cilium-values-full.yaml.partial rename to bootstrap/templates/partials/cilium-values-full.partial.yaml.j2 diff --git a/bootstrap/templates/partials/cilium-values-init.yaml.partial b/bootstrap/templates/partials/cilium-values-init.partial.yaml.j2 similarity index 100% rename from bootstrap/templates/partials/cilium-values-init.yaml.partial rename to bootstrap/templates/partials/cilium-values-init.partial.yaml.j2 diff --git a/makejinja.toml b/makejinja.toml index 603c6c1b230..9a3e473e18a 100644 --- a/makejinja.toml +++ b/makejinja.toml @@ -1,7 +1,7 @@ [makejinja] inputs = ["./bootstrap/templates"] output = "./" -exclude_patterns = ["*.partial"] +exclude_patterns = ["*.partial.yaml.j2"] data = ["./bootstrap/vars/addons.yaml", "./bootstrap/vars/config.yaml"] import_paths = ["./bootstrap/scripts"] loaders = ["loader:Loader"]