Compare commits

..

1 Commits

Author SHA1 Message Date
b0e146241b Added template for config generation script 2025-11-09 02:05:26 +01:00
2 changed files with 6 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
set -euo pipefail set -euo pipefail
ROOT=$(git rev-parse --show-toplevel) ROOT=$(git rev-parse --show-toplevel)
CONFIGS=${ROOT}/configs CONFIGS=${ROOT}/configs
TALOSCONFIG=${CONFIGS}/talosconfig
# Generate the configuration for each node # Generate the configuration for each node
{% set clusters = [] %} {% set clusters = [] %}
@@ -35,7 +36,6 @@ talosctl gen config {{ cluster[0] }} https://{{ cluster[1] }}:6443 -f \
{% endfor %} {% endfor %}
# Create merged talosconfig # Create merged talosconfig
export TALOSCONFIG=${CONFIGS}/talosconfig
rm -f ${TALOSCONFIG} rm -f ${TALOSCONFIG}
{% for cluster in clusters|unique -%} {% for cluster in clusters|unique -%}
talosctl config merge ${CONFIGS}/{{ cluster[0] }}/talosconfig talosctl config merge ${CONFIGS}/{{ cluster[0] }}/talosconfig

View File

@@ -124,10 +124,10 @@ def main():
yml_data["filename"] = filename yml_data["filename"] = filename
nodes.append(yml_data) nodes.append(yml_data)
final_nodes = []
for node in nodes:
# Quick and dirty way to resolve all the templates using a custom encoder # Quick and dirty way to resolve all the templates using a custom encoder
nodes = list( final_nodes.append(json.loads(json.dumps(node, cls=node_encoder(node))))
map(lambda node: json.loads(json.dumps(node, cls=node_encoder(node))), nodes)
)
with open(ROOT.joinpath("config.yaml")) as fyaml: with open(ROOT.joinpath("config.yaml")) as fyaml:
config = yaml.safe_load(fyaml) config = yaml.safe_load(fyaml)
@@ -136,7 +136,7 @@ def main():
for template_name in TEMPLATES.list_templates(): for template_name in TEMPLATES.list_templates():
template = TEMPLATES.get_template(template_name) template = TEMPLATES.get_template(template_name)
rendered = template.render(nodes=nodes, config=config) rendered = template.render(nodes=final_nodes, config=config)
with open(RENDERED.joinpath(template_name), "w") as f: with open(RENDERED.joinpath(template_name), "w") as f:
f.write(rendered) f.write(rendered)