Skip to content

Commit

Permalink
fix: ansible dir should only exist for k3s and k0s (#1191)
Browse files Browse the repository at this point in the history
* fix: ansible dir should only exist for k3s and k0s

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: rename partial files

Signed-off-by: Devin Buhl <devin@buhl.casa>

---------

Signed-off-by: Devin Buhl <devin@buhl.casa>
  • Loading branch information
onedr0p committed Jan 18, 2024
1 parent bae0be1 commit 0c4f026
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions bootstrap/templates/ansible/.ansible-lint.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %#
skip_list:
- yaml[commas]
- yaml[line-length]
Expand All @@ -7,3 +8,4 @@ warn_list:
- deprecated-command-syntax
- experimental
- no-changed-when
#% endif %#
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %#
---
timezone: "#{ bootstrap_timezone }#"
github_username: "#{ bootstrap_github_username }#"
Expand All @@ -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 %#
2 changes: 2 additions & 0 deletions bootstrap/templates/ansible/inventory/hosts.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %#
---
kubernetes:
children:
Expand Down Expand Up @@ -25,3 +26,4 @@ kubernetes:
#% endif %#
#% endfor %#
#% endif %#
#% endif %#
6 changes: 2 additions & 4 deletions bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#% if bootstrap_distribution == 'k3s' %#
---
- name: Cluster Nuke
hosts: kubernetes
Expand All @@ -21,7 +22,6 @@
ansible.builtin.pause:
seconds: 5
tasks:
#% if bootstrap_distribution == "k3s" %#
- name: Stop Kubernetes # noqa: ignore-errors
ignore_errors: true
block:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -92,7 +90,6 @@
path: "{{ k3s_install_dir }}/{{ item }}"
state: absent
loop: ["kubectl", "crictl", "ctr"]
#% endif %#

- name: Remove local storage path
ansible.builtin.file:
Expand All @@ -103,3 +100,4 @@
ansible.builtin.reboot:
msg: Rebooting nodes
reboot_timeout: 3600
#% endif %#
2 changes: 2 additions & 0 deletions bootstrap/templates/ansible/playbooks/cluster-prepare.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %#
---
- name: Prepare System
hosts: kubernetes
Expand Down Expand Up @@ -130,3 +131,4 @@
ansible.builtin.reboot:
msg: Rebooting nodes
reboot_timeout: 3600
#% endif %#
2 changes: 2 additions & 0 deletions bootstrap/templates/ansible/playbooks/cluster-reboot.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#% if bootstrap_distribution == 'k3s' or bootstrap_distribution == 'k0s' %#
---
- name: Reboot
hosts: kubernetes
Expand All @@ -13,3 +14,4 @@
ansible.builtin.reboot:
msg: Rebooting nodes
reboot_timeout: 3600
#% endif %#
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -86,3 +87,4 @@
#% endif %#
state: uncordon
delegate_to: "{{ groups['master'][0] }}"
#% endif %#
Original file line number Diff line number Diff line change
Expand Up @@ -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 %#
Original file line number Diff line number Diff line change
Expand Up @@ -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 %#
2 changes: 1 addition & 1 deletion bootstrap/templates/kubernetes/k0s/k0sctl.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %#
2 changes: 1 addition & 1 deletion makejinja.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down

0 comments on commit 0c4f026

Please sign in to comment.