feat: change jinja variable start/end delimiters to avoid conflicts with go templating (#1168)

* feat: change jinja variable start/end delimiters to avoid conflicts with go templating

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

* chore: update comment in makejinja.toml

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

* chore: update comment in makejinja.toml

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

---------

Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
Devin Buhl authored and GitHub committed 2024-01-16 09:25:12 -05:00
1 parent 9317007e7f
commit 646f335689
25 files changed
+80 -79

No files matched your search

+2 -2
View File
@@ -4,8 +4,8 @@ creation_rules:
encrypted_regex: "^(data|stringData)$" encrypted_regex: "^(data|stringData)$"
key_groups: key_groups:
- age: - age:
- "{% bootstrap_age_public_key %}" - "#{ bootstrap_age_public_key }#"
- path_regex: ansible/.*\.sops\.ya?ml - path_regex: ansible/.*\.sops\.ya?ml
key_groups: key_groups:
- age: - age:
- "{% bootstrap_age_public_key %}" - "#{ bootstrap_age_public_key }#"
@@ -1,16 +1,16 @@
--- ---
timezone: "{% bootstrap_timezone %}" timezone: "#{ bootstrap_timezone }#"
github_username: "{% bootstrap_github_username %}" github_username: "#{ bootstrap_github_username }#"
coredns_addr: "{% bootstrap_service_cidr.split(',')[0] | nthhost(10) %}" coredns_addr: "#{ bootstrap_service_cidr.split(',')[0] | nthhost(10) }#"
#% if bootstrap_nodes.master | length == 1 and not bootstrap_kube_api_addr %# #% if bootstrap_nodes.master | length == 1 and not bootstrap_kube_api_addr %#
kube_api_addr: "{% bootstrap_nodes.master[0].address %}" kube_api_addr: "#{ bootstrap_nodes.master[0].address }#"
#% else %# #% else %#
kube_api_addr: "{% bootstrap_kube_api_addr %}" kube_api_addr: "#{ bootstrap_kube_api_addr }#"
#% endif %# #% endif %#
cluster_cidr: "{% bootstrap_cluster_cidr.split(',')[0] %}" cluster_cidr: "#{ bootstrap_cluster_cidr.split(',')[0] }#"
service_cidr: "{% bootstrap_service_cidr.split(',')[0] %}" service_cidr: "#{ bootstrap_service_cidr.split(',')[0] }#"
node_cidr: "{% bootstrap_node_cidr %}" node_cidr: "#{ bootstrap_node_cidr }#"
#% if bootstrap_ipv6_enabled | default(false) %# #% if bootstrap_ipv6_enabled | default(false) %#
cluster_cidr_v6: "{% bootstrap_cluster_cidr.split(',')[1] %}" cluster_cidr_v6: "#{ bootstrap_cluster_cidr.split(',')[1] }#"
service_cidr_v6: "{% bootstrap_service_cidr.split(',')[1] %}" service_cidr_v6: "#{ bootstrap_service_cidr.split(',')[1] }#"
#% endif %# #% endif %#
@@ -4,24 +4,24 @@ kubernetes:
master: master:
hosts: hosts:
#% for item in bootstrap_nodes.master %# #% for item in bootstrap_nodes.master %#
"{% item.name %}": "#{ item.name }#":
ansible_user: "{% item.username %}" ansible_user: "#{ item.username }#"
#% if item.external_address is defined %# #% if item.external_address is defined %#
ansible_host: "{% item.external_address %}" ansible_host: "#{ item.external_address }#"
#% else %# #% else %#
ansible_host: "{% item.address %}" ansible_host: "#{ item.address }#"
#% endif %# #% endif %#
#% endfor %# #% endfor %#
#% if bootstrap_nodes.worker | default([]) | length > 0 %# #% if bootstrap_nodes.worker | default([]) | length > 0 %#
worker: worker:
hosts: hosts:
#% for item in bootstrap_nodes.worker %# #% for item in bootstrap_nodes.worker %#
"{% item.name %}": "#{ item.name }#":
ansible_user: "{% item.username %}" ansible_user: "#{ item.username }#"
#% if item.external_address is defined %# #% if item.external_address is defined %#
ansible_host: "{% item.external_address %}" ansible_host: "#{ item.external_address }#"
#% else %# #% else %#
ansible_host: "{% item.address %}" ansible_host: "#{ item.address }#"
#% endif %# #% endif %#
#% endfor %# #% endfor %#
#% endif %# #% endif %#
@@ -96,7 +96,7 @@
- name: Remove local storage path - name: Remove local storage path
ansible.builtin.file: ansible.builtin.file:
path: "{% bootstrap_local_storage_path %}" path: "#{ bootstrap_local_storage_path }#"
state: absent state: absent
- name: Reboot - name: Reboot
@@ -53,7 +53,7 @@ spec:
#% endif %# #% endif %#
loadBalancer: loadBalancer:
algorithm: maglev algorithm: maglev
mode: "{% bootstrap_cilium_loadbalancer_mode | default('dsr', true) %}" mode: "#{ bootstrap_cilium_loadbalancer_mode | default('dsr', true) }#"
localRedirectPolicy: true localRedirectPolicy: true
operator: operator:
replicas: 1 replicas: 1
+14 -14
View File
@@ -7,10 +7,10 @@ metadata:
spec: spec:
hosts: hosts:
#% for item in bootstrap_nodes.master %# #% for item in bootstrap_nodes.master %#
- role: "{% item.role | default('controller+worker') %}" - role: "#{ item.role | default('controller+worker') }#"
ssh: ssh:
address: "{% item.address %}" address: "#{ item.address }#"
user: "{% item.username %}" user: "#{ item.username }#"
installFlags: installFlags:
- --disable-components=metrics-server - --disable-components=metrics-server
#% if item.role | default('') == 'controller+worker' %# #% if item.role | default('') == 'controller+worker' %#
@@ -21,8 +21,8 @@ spec:
#% for item in bootstrap_nodes.worker %# #% for item in bootstrap_nodes.worker %#
- role: worker - role: worker
ssh: ssh:
address: "{% item.address %}" address: "#{ item.address }#"
user: "{% item.username %}" user: "#{ item.username }#"
#% endfor %# #% endfor %#
#% endif %# #% endif %#
k0s: k0s:
@@ -43,16 +43,16 @@ spec:
bind-address: "0.0.0.0" bind-address: "0.0.0.0"
api: api:
sans: sans:
- "{% bootstrap_kube_api_addr %}" - "#{ bootstrap_kube_api_addr }#"
#% if bootstrap_kubeapi_hostname is defined %# #% if bootstrap_kubeapi_hostname is defined %#
- "{% bootstrap_kubeapi_hostname %}" - "#{ bootstrap_kubeapi_hostname }#"
#% endif %# #% endif %#
#% for item in bootstrap_nodes.master %# #% for item in bootstrap_nodes.master %#
#% if item.address != bootstrap_kube_api_addr %# #% if item.address != bootstrap_kube_api_addr %#
- "{% item.address %}" - "#{ item.address }#"
#% endif %# #% endif %#
#% if (bootstrap_kubeapi_hostname is not defined) or (item.name != bootstrap_kubeapi_hostname) %# #% if (bootstrap_kubeapi_hostname is not defined) or (item.name != bootstrap_kubeapi_hostname) %#
- "{% item.name %}" - "#{ item.name }#"
#% endif %# #% endif %#
#% endfor %# #% endfor %#
extensions: extensions:
@@ -84,16 +84,16 @@ spec:
enabled: false enabled: false
ipam: ipam:
mode: kubernetes mode: kubernetes
ipv4NativeRoutingCIDR: "{% bootstrap_cluster_cidr %}" ipv4NativeRoutingCIDR: "#{ bootstrap_cluster_cidr }#"
#% if bootstrap_ipv6_enabled | default(false) %# #% if bootstrap_ipv6_enabled | default(false) %#
ipv6NativeRoutingCIDR: "{% bootstrap_cluster_cidr_v6 %}" ipv6NativeRoutingCIDR: "#{ bootstrap_cluster_cidr_v6 }#"
ipv6: ipv6:
enabled: true enabled: true
#% endif %# #% endif %#
#% if bootstrap_nodes.master | length == 1 and not bootstrap_kube_api_addr %# #% if bootstrap_nodes.master | length == 1 and not bootstrap_kube_api_addr %#
k8sServiceHost: "{% bootstrap_nodes.master[0].address %}" k8sServiceHost: "#{ bootstrap_nodes.master[0].address }#"
#% else %# #% else %#
k8sServiceHost: "{% bootstrap_kube_api_addr %}" k8sServiceHost: "#{ bootstrap_kube_api_addr }#"
#% endif %# #% endif %#
k8sServicePort: 6443 k8sServicePort: 6443
kubeProxyReplacement: true kubeProxyReplacement: true
@@ -110,7 +110,7 @@ spec:
#% endif %# #% endif %#
loadBalancer: loadBalancer:
algorithm: maglev algorithm: maglev
mode: "{% bootstrap_cilium_loadbalancer_mode | default('dsr', true) %}" mode: "#{ bootstrap_cilium_loadbalancer_mode | default('dsr', true) }#"
localRedirectPolicy: true localRedirectPolicy: true
operator: operator:
replicas: 1 replicas: 1
@@ -4,4 +4,4 @@ kind: Secret
metadata: metadata:
name: cert-manager-secret name: cert-manager-secret
stringData: stringData:
api-token: "{% bootstrap_cloudflare_token %}" api-token: "#{ bootstrap_cloudflare_token }#"
@@ -12,5 +12,5 @@ stringData:
interval = "10m" interval = "10m"
retry_limit = 5 retry_limit = 5
sink.type = "discord" sink.type = "discord"
sink.url = "{% discord_template_notifier.webhook_url %}" sink.url = "#{ discord_template_notifier.webhook_url }#"
#% endif %# #% endif %#
@@ -5,9 +5,9 @@ kind: Secret
metadata: metadata:
name: homepage-secret name: homepage-secret
stringData: stringData:
HOMEPAGE_VAR_CLOUDFLARED_ACCOUNTID: "{% bootstrap_cloudflare_account_tag %}" HOMEPAGE_VAR_CLOUDFLARED_ACCOUNTID: "#{ bootstrap_cloudflare_account_tag }#"
HOMEPAGE_VAR_CLOUDFLARED_TUNNELID: "{% bootstrap_cloudflare_tunnel_id %}" HOMEPAGE_VAR_CLOUDFLARED_TUNNELID: "#{ bootstrap_cloudflare_tunnel_id }#"
HOMEPAGE_VAR_CLOUDFLARED_API_TOKEN: "{% bootstrap_cloudflare_token %}" HOMEPAGE_VAR_CLOUDFLARED_API_TOKEN: "#{ bootstrap_cloudflare_token }#"
HOMEPAGE_VAR_GRAFANA_USERNAME: admin HOMEPAGE_VAR_GRAFANA_USERNAME: admin
HOMEPAGE_VAR_GRAFANA_PASSWORD: "{% grafana.password %}" HOMEPAGE_VAR_GRAFANA_PASSWORD: "#{ grafana.password }#"
#% endif %# #% endif %#
@@ -4,4 +4,4 @@ kind: Secret
metadata: metadata:
name: github-webhook-token-secret name: github-webhook-token-secret
stringData: stringData:
token: "{% bootstrap_flux_github_webhook_token %}" token: "#{ bootstrap_flux_github_webhook_token }#"
@@ -7,5 +7,5 @@ metadata:
type: Opaque type: Opaque
stringData: stringData:
username: admin username: admin
password: "{% weave_gitops.password | encrypt %}" password: "#{ weave_gitops.password | encrypt }#"
#% endif %# #% endif %#
@@ -106,7 +106,7 @@ spec:
#% endif %# #% endif %#
loadBalancer: loadBalancer:
algorithm: maglev algorithm: maglev
mode: "{% bootstrap_cilium_loadbalancer_mode | default('dsr', true) %}" mode: "#{ bootstrap_cilium_loadbalancer_mode | default('dsr', true) }#"
localRedirectPolicy: true localRedirectPolicy: true
operator: operator:
replicas: 1 replicas: 1
@@ -4,10 +4,10 @@ kind: Secret
metadata: metadata:
name: cloudflared-secret name: cloudflared-secret
stringData: stringData:
TUNNEL_ID: "{% bootstrap_cloudflare_tunnel_id %}" TUNNEL_ID: "#{ bootstrap_cloudflare_tunnel_id }#"
credentials.json: | credentials.json: |
{ {
"AccountTag": "{% bootstrap_cloudflare_account_tag %}", "AccountTag": "#{ bootstrap_cloudflare_account_tag }#",
"TunnelSecret": "{% bootstrap_cloudflare_tunnel_secret %}", "TunnelSecret": "#{ bootstrap_cloudflare_tunnel_secret }#",
"TunnelID": "{% bootstrap_cloudflare_tunnel_id %}" "TunnelID": "#{ bootstrap_cloudflare_tunnel_id }#"
} }
@@ -4,4 +4,4 @@ kind: Secret
metadata: metadata:
name: external-dns-secret name: external-dns-secret
stringData: stringData:
api-token: "{% bootstrap_cloudflare_token %}" api-token: "#{ bootstrap_cloudflare_token }#"
@@ -31,5 +31,5 @@ spec:
type: LoadBalancer type: LoadBalancer
port: 53 port: 53
annotations: annotations:
io.cilium/lb-ipam-ips: "{% bootstrap_k8s_gateway_addr %}" io.cilium/lb-ipam-ips: "#{ bootstrap_k8s_gateway_addr }#"
externalTrafficPolicy: Cluster externalTrafficPolicy: Cluster
@@ -33,7 +33,7 @@ spec:
service: service:
annotations: annotations:
external-dns.alpha.kubernetes.io/hostname: "external.${SECRET_DOMAIN}" external-dns.alpha.kubernetes.io/hostname: "external.${SECRET_DOMAIN}"
io.cilium/lb-ipam-ips: "{% bootstrap_external_ingress_addr %}" io.cilium/lb-ipam-ips: "#{ bootstrap_external_ingress_addr }#"
externalTrafficPolicy: Cluster externalTrafficPolicy: Cluster
ingressClassResource: ingressClassResource:
name: external name: external
@@ -31,7 +31,7 @@ spec:
service: service:
annotations: annotations:
external-dns.alpha.kubernetes.io/hostname: "internal.${SECRET_DOMAIN}" external-dns.alpha.kubernetes.io/hostname: "internal.${SECRET_DOMAIN}"
io.cilium/lb-ipam-ips: "{% bootstrap_internal_ingress_addr %}" io.cilium/lb-ipam-ips: "#{ bootstrap_internal_ingress_addr }#"
externalTrafficPolicy: Cluster externalTrafficPolicy: Cluster
ingressClassResource: ingressClassResource:
name: internal name: internal
@@ -6,5 +6,5 @@ metadata:
name: grafana-admin-secret name: grafana-admin-secret
stringData: stringData:
admin-user: admin admin-user: admin
admin-password: "{% grafana.password %}" admin-password: "#{ grafana.password }#"
#% endif %# #% endif %#
@@ -92,7 +92,7 @@ spec:
enabled: true enabled: true
endpoints: &endpoints endpoints: &endpoints
#% for item in bootstrap_nodes.master %# #% for item in bootstrap_nodes.master %#
- "{% item.address %}" - "#{ item.address }#"
#% endfor %# #% endfor %#
#% if bootstrap_distribution == 'k3s' %# #% if bootstrap_distribution == 'k3s' %#
serviceMonitor: serviceMonitor:
@@ -4,11 +4,11 @@
apiVersion: storage.k8s.io/v1 apiVersion: storage.k8s.io/v1
kind: StorageClass kind: StorageClass
metadata: metadata:
name: "{% item.name %}" name: "#{ item.name }#"
provisioner: nfs.csi.k8s.io provisioner: nfs.csi.k8s.io
parameters: parameters:
server: "{% item.server %}" server: "#{ item.server }#"
share: "{% item.share %}" share: "#{ item.share }#"
reclaimPolicy: Delete reclaimPolicy: Delete
volumeBindingMode: Immediate volumeBindingMode: Immediate
mountOptions: ["hard", "noatime"] mountOptions: ["hard", "noatime"]
@@ -29,5 +29,5 @@ spec:
enabled: true enabled: true
name: openebs-hostpath name: openebs-hostpath
isDefaultClass: false isDefaultClass: false
basePath: "{% bootstrap_local_storage_path %}" basePath: "#{ bootstrap_local_storage_path }#"
@@ -7,13 +7,13 @@ metadata:
spec: spec:
interval: 30m interval: 30m
ref: ref:
branch: "{% bootstrap_github_repository_branch | default('main', true) %}" branch: "#{ bootstrap_github_repository_branch | default('main', true) }#"
#% if bootstrap_private_github_repo | default(false) %# #% if bootstrap_private_github_repo | default(false) %#
secretRef: secretRef:
name: github-deploy-key name: github-deploy-key
url: "ssh://github.com/{% bootstrap_github_username %}/{% bootstrap_github_repository_name %}" url: "ssh://github.com/#{ bootstrap_github_username }#/#{ bootstrap_github_repository_name }#"
#% else %# #% else %#
url: "https://github.com/{% bootstrap_github_username %}/{% bootstrap_github_repository_name %}.git" url: "https://github.com/#{ bootstrap_github_username }#/#{ bootstrap_github_repository_name }#.git"
#% endif %# #% endif %#
ignore: | ignore: |
# exclude all # exclude all
@@ -5,6 +5,6 @@ metadata:
name: cluster-secrets name: cluster-secrets
namespace: flux-system namespace: flux-system
stringData: stringData:
SECRET_DOMAIN: "{% bootstrap_cloudflare_domain %}" SECRET_DOMAIN: "#{ bootstrap_cloudflare_domain }#"
SECRET_ACME_EMAIL: "{% bootstrap_acme_email %}" SECRET_ACME_EMAIL: "#{ bootstrap_acme_email }#"
SECRET_CLOUDFLARE_TUNNEL_ID: "{% bootstrap_cloudflare_tunnel_id %}" SECRET_CLOUDFLARE_TUNNEL_ID: "#{ bootstrap_cloudflare_tunnel_id }#"
@@ -5,17 +5,17 @@ metadata:
name: cluster-settings name: cluster-settings
namespace: flux-system namespace: flux-system
data: data:
TIMEZONE: "{% bootstrap_timezone %}" TIMEZONE: "#{ bootstrap_timezone }#"
COREDNS_ADDR: "{% bootstrap_service_cidr.split(',')[0] | nthhost(10) %}" COREDNS_ADDR: "#{ bootstrap_service_cidr.split(',')[0] | nthhost(10) }#"
#% if bootstrap_nodes.master | length == 1 and not bootstrap_kube_api_addr %# #% if bootstrap_nodes.master | length == 1 and not bootstrap_kube_api_addr %#
KUBE_API_ADDR: "{% bootstrap_nodes.master[0].address %}" KUBE_API_ADDR: "#{ bootstrap_nodes.master[0].address }#"
#% else %# #% else %#
KUBE_API_ADDR: "{% bootstrap_kube_api_addr %}" KUBE_API_ADDR: "#{ bootstrap_kube_api_addr }#"
#% endif %# #% endif %#
CLUSTER_CIDR: "{% bootstrap_cluster_cidr.split(',')[0] %}" CLUSTER_CIDR: "#{ bootstrap_cluster_cidr.split(',')[0] }#"
SERVICE_CIDR: "{% bootstrap_service_cidr.split(',')[0] %}" SERVICE_CIDR: "#{ bootstrap_service_cidr.split(',')[0] }#"
NODE_CIDR: "{% bootstrap_node_cidr %}" NODE_CIDR: "#{ bootstrap_node_cidr }#"
#% if bootstrap_ipv6_enabled | default(false) %# #% if bootstrap_ipv6_enabled | default(false) %#
CLUSTER_CIDR_V6: "{% bootstrap_cluster_cidr.split(',')[1] %}" CLUSTER_CIDR_V6: "#{ bootstrap_cluster_cidr.split(',')[1] }#"
SERVICE_CIDR_V6: "{% bootstrap_service_cidr.split(',')[1] %}" SERVICE_CIDR_V6: "#{ bootstrap_service_cidr.split(',')[1] }#"
#% endif %# #% endif %#
+6 -5
View File
@@ -6,12 +6,13 @@ import_paths = ["./bootstrap/scripts"]
loaders = ["loader:Loader"] loaders = ["loader:Loader"]
jinja_suffix = ".j2" jinja_suffix = ".j2"
# Block delimiters are changed to avoid conflicts with Renovate # Block and comment delimiters are changed to avoid conflicts with Renovate
# Variable delimiters are changed to avoid conflicts with Renovate and Go templates
# https://github.com/renovatebot/renovate/discussions/18470 # https://github.com/renovatebot/renovate/discussions/18470
[makejinja.delimiter] [makejinja.delimiter]
block_start = "#%" block_start = "#%"
block_end = "%#" block_end = "%#"
comment_start = "{#" comment_start = "#|"
comment_end = "#}" comment_end = "|#"
variable_start = "{%" variable_start = "#{"
variable_end = "%}" variable_end = "}#"