This allows for embedding the repo root inside of, for example, scripts to make them function properly no matter where they are run from.
41 lines
1.5 KiB
Bash
41 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
ROOT={{ root }}
|
|
CONFIGS=${ROOT}/configs
|
|
|
|
# Generate the configuration for each node
|
|
{% for node in nodes -%}
|
|
talosctl gen config {{ node.clusterName }} https://{{ node.controlplaneIp }}:6443 -f \
|
|
--with-secrets ${ROOT}/secrets.yaml \
|
|
--talos-version {{ node.talosVersion }} \
|
|
--kubernetes-version {{ node.kubernesVersion }} \
|
|
--output-types {{ node.type }} \
|
|
--install-image factory.talos.dev/metal-installer/{{ node.schematicId }}:{{ node.talosVersion }} \
|
|
{% for patch in node.patches -%}
|
|
{# The double call to tojson is needed to properly escape the patch (object -> json -> string) -#}
|
|
--config-patch {{ patch|tojson|tojson }} \
|
|
{% endfor -%}
|
|
{% for patch in node.patchesControlplane -%}
|
|
--config-patch-control-plane {{ patch|tojson|tojson }} \
|
|
{% endfor -%}
|
|
--with-docs=false \
|
|
--with-examples=false \
|
|
-o ${CONFIGS}/{{ node.filename }}.yaml
|
|
{% endfor %}
|
|
|
|
# Generate the talosconfig file for each cluster
|
|
{# NOTE: This assumes that each node in a cluster specifies the same controlplane IP -#}
|
|
{% for cluster in clusters -%}
|
|
talosctl gen config {{ cluster.name }} https://{{ cluster.controlplaneIp }}:6443 -f \
|
|
--with-secrets ${ROOT}/secrets.yaml \
|
|
--output-types talosconfig \
|
|
-o ${CONFIGS}/{{ cluster.name }}/talosconfig
|
|
{% endfor %}
|
|
|
|
# Create merged talosconfig
|
|
export TALOSCONFIG=${CONFIGS}/talosconfig
|
|
rm -f ${TALOSCONFIG}
|
|
{% for cluster in clusters -%}
|
|
talosctl config merge ${CONFIGS}/{{ cluster.name }}/talosconfig
|
|
{% endfor %}
|