Moved logic for getting clusters to render script
This commit is contained in:
@@ -4,8 +4,7 @@ ROOT=$(git rev-parse --show-toplevel)
|
||||
CONFIGS=${ROOT}/configs
|
||||
|
||||
# Generate the configuration for each node
|
||||
{% set clusters = [] %}
|
||||
{%- for node in nodes -%}
|
||||
{% for node in nodes -%}
|
||||
talosctl gen config {{ node.clusterName }} https://{{ node.controlplaneIp }}:6443 -f \
|
||||
--with-secrets ${ROOT}/secrets.yaml \
|
||||
--talos-version {{ node.talosVersion }} \
|
||||
@@ -22,21 +21,20 @@ talosctl gen config {{ node.clusterName }} https://{{ node.controlplaneIp }}:644
|
||||
--with-docs=false \
|
||||
--with-examples=false \
|
||||
-o ${CONFIGS}/{{ node.filename }}.yaml
|
||||
|
||||
{%- do clusters.append((node.clusterName, node.controlplaneIp)) %}
|
||||
{% endfor %}
|
||||
|
||||
# Generate the talosconfig file for each cluster
|
||||
{% for cluster in clusters|unique -%}
|
||||
talosctl gen config {{ cluster[0] }} https://{{ cluster[1] }}:6443 -f \
|
||||
{# 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[0] }}/talosconfig
|
||||
-o ${CONFIGS}/{{ cluster.name }}/talosconfig
|
||||
{% endfor %}
|
||||
|
||||
# Create merged talosconfig
|
||||
export TALOSCONFIG=${CONFIGS}/talosconfig
|
||||
rm -f ${TALOSCONFIG}
|
||||
{% for cluster in clusters|unique -%}
|
||||
talosctl config merge ${CONFIGS}/{{ cluster[0] }}/talosconfig
|
||||
{% for cluster in clusters -%}
|
||||
talosctl config merge ${CONFIGS}/{{ cluster.name }}/talosconfig
|
||||
{% endfor %}
|
||||
|
||||
12
tools/render
12
tools/render
@@ -134,6 +134,16 @@ def main():
|
||||
)
|
||||
)
|
||||
|
||||
# Get all clusterName & controlplaneIp pairs
|
||||
clusters = map(
|
||||
lambda node: {
|
||||
"name": node["clusterName"],
|
||||
"controlplaneIp": node["controlplaneIp"],
|
||||
},
|
||||
nodes,
|
||||
)
|
||||
clusters = [dict(s) for s in set(frozenset(d.items()) for d in clusters)]
|
||||
|
||||
with open(ROOT.joinpath("config.yaml")) as fyaml:
|
||||
config = yaml.safe_load(fyaml)
|
||||
|
||||
@@ -141,7 +151,7 @@ def main():
|
||||
for template_name in TEMPLATES.list_templates():
|
||||
template = TEMPLATES.get_template(template_name)
|
||||
|
||||
rendered = template.render(nodes=nodes, config=config)
|
||||
rendered = template.render(nodes=nodes, clusters=clusters, config=config)
|
||||
with open(RENDERED.joinpath(template_name), "w") as f:
|
||||
f.write(rendered)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user