Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change jinja block/start delimiters for renovate support #1163

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"schedule": ["on saturday"],
"flux": {
"fileMatch": [
"(^|/)addons/.+\\.ya?ml(\\.j2)?(\\.j2)?$",
"(^|/)ansible/.+\\.ya?ml(\\.j2)?(\\.j2)?$",
"(^|/)kubernetes/.+\\.ya?ml(\\.j2)?(\\.j2)?$"
]
Expand Down Expand Up @@ -228,11 +227,16 @@
"(^|/)k0s-config.ya?ml(\\.j2)?(\\.j2)?$"
],
"matchStrings": [
// Example: `k3s_release_version: "v1.27.3+k3s1"`
// Example:
// k3s_release_version: "v1.27.3+k3s1"
"datasource=(?<datasource>\\S+) depName=(?<depName>\\S+)( versioning=(?<versioning>\\S+))?\n.*?\"(?<currentValue>.*)\"\n",
// Example: `- https://github.com/rancher/system-upgrade-controller/releases/download/v0.11.0/crd.yaml`
// Example:
// - https://github.com/rancher/system-upgrade-controller/releases/download/v0.11.0/crd.yaml
"datasource=(?<datasource>\\S+) depName=(?<depName>\\S+)( versioning=(?<versioning>\\S+))?\n.*?-\\s(.*?)\/(?<currentValue>[^/]+)\/[^/]+\n",
// Example: apiVersion=helm.cattle.io/v1 kind=HelmChart
// Example:
// repo: https://helm.cilium.io
// chart: cilium
// version: 1.14.5
"datasource=(?<datasource>\\S+)\n.*?repo: (?<registryUrl>\\S+)\n.*?chart: (?<depName>\\S+)\n.*?version: (?<currentValue>\\S+)\n"
],
"datasourceTemplate": "{{#if datasource}}{{{datasource}}}{{else}}github-releases{{/if}}",
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/templates/.sops.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ creation_rules:
encrypted_regex: "^(data|stringData)$"
key_groups:
- age:
- "<< bootstrap_age_public_key >>"
- "{% bootstrap_age_public_key %}"
- path_regex: ansible/.*\.sops\.ya?ml
key_groups:
- age:
- "<< bootstrap_age_public_key >>"
- "{% bootstrap_age_public_key %}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
---
#
# Below vars are for the xanmanning.k3s role
Expand All @@ -9,23 +9,23 @@
k3s_release_version: "v1.29.0+k3s1"
k3s_install_hard_links: true
k3s_become: true
<% if bootstrap_nodes.master | length > 1 %>
#% if bootstrap_nodes.master | length > 1 %#
k3s_etcd_datastore: true
<% else %>
#% else %#
k3s_etcd_datastore: false
<% endif %>
#% endif %#
k3s_registration_address: "{{ kube_api_addr }}"
# /var/lib/rancher/k3s/server/manifests
k3s_server_manifests_templates:
- custom-cilium-helmchart.yaml.j2
- custom-coredns-helmchart.yaml.j2
<% if bootstrap_nodes.master | length > 1 and not bootstrap_kube_api_addr %>
#% if bootstrap_nodes.master | length > 1 and not bootstrap_kube_api_addr %#
# /var/lib/rancher/k3s/server/manifests
k3s_server_manifests_urls:
- url: https://raw.githubusercontent.com/kube-vip/website/main/content/manifests/rbac.yaml
filename: kube-vip-rbac.yaml
# /var/lib/rancher/k3s/agent/pod-manifests
k3s_server_pod_manifests_templates:
- kube-vip-static-pod.yaml.j2
<% endif %>
<% endif %>
#% endif %#
#% endif %#
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
timezone: "<< bootstrap_timezone >>"
github_username: "<< bootstrap_github_username >>"
coredns_addr: "<< bootstrap_service_cidr.split(',')[0] | nthhost(10) >>"
<% if bootstrap_nodes.master | length == 1 and not bootstrap_kube_api_addr %>
kube_api_addr: "<< bootstrap_nodes.master[0].address >>"
<% else %>
kube_api_addr: "<< bootstrap_kube_api_addr >>"
<% endif %>
cluster_cidr: "<< bootstrap_cluster_cidr.split(',')[0] >>"
service_cidr: "<< bootstrap_service_cidr.split(',')[0] >>"
node_cidr: "<< bootstrap_node_cidr >>"
<% if bootstrap_ipv6_enabled | default(false) %>
cluster_cidr_v6: "<< bootstrap_cluster_cidr.split(',')[1] >>"
service_cidr_v6: "<< bootstrap_service_cidr.split(',')[1] >>"
<% endif %>
timezone: "{% bootstrap_timezone %}"
github_username: "{% bootstrap_github_username %}"
coredns_addr: "{% bootstrap_service_cidr.split(',')[0] | nthhost(10) %}"
#% if bootstrap_nodes.master | length == 1 and not bootstrap_kube_api_addr %#
kube_api_addr: "{% bootstrap_nodes.master[0].address %}"
#% else %#
kube_api_addr: "{% bootstrap_kube_api_addr %}"
#% endif %#
cluster_cidr: "{% bootstrap_cluster_cidr.split(',')[0] %}"
service_cidr: "{% bootstrap_service_cidr.split(',')[0] %}"
node_cidr: "{% bootstrap_node_cidr %}"
#% if bootstrap_ipv6_enabled | default(false) %#
cluster_cidr_v6: "{% bootstrap_cluster_cidr.split(',')[1] %}"
service_cidr_v6: "{% bootstrap_service_cidr.split(',')[1] %}"
#% endif %#
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
---
# https://rancher.com/docs/k3s/latest/en/installation/install-options/server-config/
# https://github.com/PyratLabs/ansible-role-k3s

k3s_control_node: true
k3s_server:
<% if bootstrap_ipv6_enabled | default(false) %>
#% if bootstrap_ipv6_enabled | default(false) %#
node-ip: "{{ ansible_host }},{{ ansible_default_ipv6.address }}"
<% else %>
#% else %#
node-ip: "{{ ansible_host }}"
<% endif %>
#% endif %#
tls-san:
- "{{ kube_api_addr }}"
docker: false
Expand All @@ -27,13 +27,13 @@ k3s_server:
write-kubeconfig-mode: "644"
pause-image: registry.k8s.io/pause:3.9
secrets-encryption: true
<% if bootstrap_ipv6_enabled | default(false) %>
#% if bootstrap_ipv6_enabled | default(false) %#
cluster-cidr: "{{ cluster_cidr }},{{ cluster_cidr_v6 }}"
service-cidr: "{{ service_cidr }},{{ service_cidr_v6 }}"
<% else %>
#% else %#
cluster-cidr: "{{ cluster_cidr }}"
service-cidr: "{{ service_cidr }}"
<% endif %>
#% endif %#
etcd-expose-metrics: true # Required to monitor etcd with kube-prometheus-stack
kube-controller-manager-arg:
- "bind-address=0.0.0.0" # Required to monitor kube-controller-manager with kube-prometheus-stack
Expand All @@ -45,4 +45,4 @@ k3s_server:
kubelet-arg:
- "image-gc-high-threshold=55"
- "image-gc-low-threshold=50"
<% endif %>
#% endif %#
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
---
# https://rancher.com/docs/k3s/latest/en/installation/install-options/agent-config/
# https://github.com/PyratLabs/ansible-role-k3s

k3s_control_node: false
k3s_agent:
<% if bootstrap_ipv6_enabled | default(false) %>
#% if bootstrap_ipv6_enabled | default(false) %#
node-ip: "{{ ansible_host }},{{ ansible_default_ipv6.address }}"
<% else %>
#% else %#
node-ip: "{{ ansible_host }}"
<% endif %>
#% endif %#
pause-image: registry.k8s.io/pause:3.9
# TODO: Move these options to a kubelet config file
kubelet-arg:
- "image-gc-high-threshold=55"
- "image-gc-low-threshold=50"
<% endif %>
#% endif %#
40 changes: 20 additions & 20 deletions bootstrap/templates/ansible/inventory/hosts.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ kubernetes:
children:
master:
hosts:
<% for item in bootstrap_nodes.master %>
<< item.name >>:
ansible_user: << item.username >>
<% if item.external_address is defined %>
ansible_host: << item.external_address >>
<% else %>
ansible_host: << item.address >>
<% endif %>
<% endfor %>
<% if bootstrap_nodes.worker | default([]) | length > 0 %>
#% for item in bootstrap_nodes.master %#
"{% item.name %}":
ansible_user: "{% item.username %}"
#% if item.external_address is defined %#
ansible_host: "{% item.external_address %}"
#% else %#
ansible_host: "{% item.address %}"
#% endif %#
#% endfor %#
#% if bootstrap_nodes.worker | default([]) | length > 0 %#
worker:
hosts:
<% for item in bootstrap_nodes.worker %>
<< item.name >>:
ansible_user: << item.username >>
<% if item.external_address is defined %>
ansible_host: << item.external_address >>
<% else %>
ansible_host: << item.address >>
<% endif %>
<% endfor %>
<% endif %>
#% for item in bootstrap_nodes.worker %#
"{% item.name %}":
ansible_user: "{% item.username %}"
#% if item.external_address is defined %#
ansible_host: "{% item.external_address %}"
#% else %#
ansible_host: "{% item.address %}"
#% endif %#
#% endfor %#
#% endif %#
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
---
- name: Cluster Installation
hosts: kubernetes
Expand Down Expand Up @@ -60,4 +60,4 @@
- name: Cruft
when: k3s_primary_control_node
ansible.builtin.include_tasks: tasks/cruft.yaml
<% endif %>
#% endif %#
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
---
- name: Cluster kube-vip
hosts: master
Expand All @@ -23,4 +23,4 @@
src: templates/kube-vip-static-pod.yaml.j2
dest: "{{ k3s_server_pod_manifests_dir }}/kube-vip-static-pod.yaml"
mode: preserve
<% endif %>
#% endif %#
10 changes: 5 additions & 5 deletions bootstrap/templates/ansible/playbooks/cluster-nuke.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
ansible.builtin.pause:
seconds: 5
tasks:
<% if bootstrap_distribution == "k3s" %>
#% if bootstrap_distribution == "k3s" %#
- name: Stop Kubernetes # noqa: ignore-errors
ignore_errors: true
block:
Expand All @@ -31,7 +31,7 @@
public: true
vars:
k3s_state: stopped
<% endif %>
#% endif %#

# https://github.com/k3s-io/docs/blob/main/docs/installation/network-options.md
- name: Networking
Expand All @@ -57,7 +57,7 @@
path: /etc/cni/net.d
state: absent

<% if bootstrap_distribution == "k3s" %>
#% 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,11 +92,11 @@
path: "{{ k3s_install_dir }}/{{ item }}"
state: absent
loop: ["kubectl", "crictl", "ctr"]
<% endif %>
#% endif %#

- name: Remove local storage path
ansible.builtin.file:
path: "<< bootstrap_local_storage_path >>"
path: "{% bootstrap_local_storage_path %}"
state: absent

- name: Reboot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
seconds: 5
tasks:
- name: Details
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
ansible.builtin.command: "k3s kubectl get node {{ inventory_hostname }} -o json"
<% elif bootstrap_distribution == 'k0s' %>
#% elif bootstrap_distribution == 'k0s' %#
ansible.builtin.command: "k0s kubectl get node {{ inventory_hostname }} -o json"
<% endif %>
#% endif %#
register: kubectl_get_node
delegate_to: "{{ groups['master'][0] }}"
failed_when: false
Expand All @@ -32,22 +32,22 @@
- name: Cordon
kubernetes.core.k8s_drain:
name: "{{ inventory_hostname }}"
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
kubeconfig: /etc/rancher/k3s/k3s.yaml
<% elif bootstrap_distribution == 'k0s' %>
#% elif bootstrap_distribution == 'k0s' %#
kubeconfig: /var/lib/k0s/pki/admin.conf
<% endif %>
#% endif %#
state: cordon
delegate_to: "{{ groups['master'][0] }}"

- name: Drain
kubernetes.core.k8s_drain:
name: "{{ inventory_hostname }}"
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
kubeconfig: /etc/rancher/k3s/k3s.yaml
<% elif bootstrap_distribution == 'k0s' %>
#% elif bootstrap_distribution == 'k0s' %#
kubeconfig: /var/lib/k0s/pki/admin.conf
<% endif %>
#% endif %#
state: drain
delete_options:
delete_emptydir_data: true
Expand Down Expand Up @@ -79,10 +79,10 @@
- name: Uncordon
kubernetes.core.k8s_drain:
name: "{{ inventory_hostname }}"
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
kubeconfig: /etc/rancher/k3s/k3s.yaml
<% elif bootstrap_distribution == 'k0s' %>
#% elif bootstrap_distribution == 'k0s' %#
kubeconfig: /var/lib/k0s/pki/admin.conf
<% endif %>
#% endif %#
state: uncordon
delegate_to: "{{ groups['master'][0] }}"
4 changes: 2 additions & 2 deletions bootstrap/templates/ansible/playbooks/tasks/cilium.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
---
- name: Cilium
block:
Expand Down Expand Up @@ -55,4 +55,4 @@
definition:
metadata:
finalizers: []
<% endif %>
#% endif %#
4 changes: 2 additions & 2 deletions bootstrap/templates/ansible/playbooks/tasks/coredns.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
---
- name: Coredns
block:
Expand Down Expand Up @@ -55,4 +55,4 @@
definition:
metadata:
finalizers: []
<% endif %>
#% endif %#
4 changes: 2 additions & 2 deletions bootstrap/templates/ansible/playbooks/tasks/cruft.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
---
# https://github.com/k3s-io/k3s/issues/1971
- name: Cruft
Expand Down Expand Up @@ -31,4 +31,4 @@
namespace: kube-system
state: absent
loop: "{{ addons_list.resources | selectattr('metadata.name', 'match', '^custom-.*') | list }}"
<% endif %>
#% endif %#
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if bootstrap_distribution == 'k3s' %>
#% if bootstrap_distribution == 'k3s' %#
---
- name: Get absolute path to this Git repository # noqa: command-instead-of-module
ansible.builtin.command: git rev-parse --show-toplevel
Expand All @@ -25,4 +25,4 @@
path: "{{ repository_path.stdout }}/kubeconfig"
regexp: https://127.0.0.1:6443
replace: "https://{{ k3s_registration_address }}:6443"
<% endif %>
#% endif %#
Loading