Compare commits
2 Commits
8b806b7a38
...
af49354786
| Author | SHA1 | Date | |
|---|---|---|---|
|
af49354786
|
|||
|
83cadd99e4
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1 +1 @@
|
|||||||
secrets.yaml filter=git-crypt diff=git-crypt
|
_secrets.yaml filter=git-crypt diff=git-crypt
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ installDisk: /dev/sda
|
|||||||
cluster:
|
cluster:
|
||||||
name: hellas
|
name: hellas
|
||||||
controlPlaneIp: 10.0.2.1
|
controlPlaneIp: 10.0.2.1
|
||||||
|
secretsFile: !realpath _secrets.yaml
|
||||||
|
|||||||
BIN
nodes/hellas/_secrets.yaml
Normal file
BIN
nodes/hellas/_secrets.yaml
Normal file
Binary file not shown.
@@ -4,3 +4,4 @@ installDisk: /dev/vda
|
|||||||
cluster:
|
cluster:
|
||||||
name: testing
|
name: testing
|
||||||
controlPlaneIp: 192.168.1.100
|
controlPlaneIp: 192.168.1.100
|
||||||
|
secretsFile: !realpath _secrets.yaml
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
ROOT={{ root }}
|
CONFIGS={{ root }}/configs
|
||||||
CONFIGS=${ROOT}/configs
|
|
||||||
|
|
||||||
# Generate the configuration for each node
|
# Generate the configuration for each node
|
||||||
{% for node in nodes -%}
|
{% for node in nodes -%}
|
||||||
talosctl gen config {{ node.cluster.name }} https://{{ node.cluster.controlPlaneIp }}:6443 -f \
|
talosctl gen config {{ node.cluster.name }} https://{{ node.cluster.controlPlaneIp }}:6443 -f \
|
||||||
--with-secrets ${ROOT}/secrets.yaml \
|
--with-secrets {{ node.cluster.secretsFile }} \
|
||||||
--talos-version {{ node.talosVersion }} \
|
--talos-version {{ node.talosVersion }} \
|
||||||
--kubernetes-version {{ node.kubernesVersion }} \
|
--kubernetes-version {{ node.kubernesVersion }} \
|
||||||
--output-types {{ node.type }} \
|
--output-types {{ node.type }} \
|
||||||
@@ -26,7 +25,7 @@ talosctl gen config {{ node.cluster.name }} https://{{ node.cluster.controlPlane
|
|||||||
# Generate the talosconfig file for each cluster
|
# Generate the talosconfig file for each cluster
|
||||||
{% for cluster in clusters -%}
|
{% for cluster in clusters -%}
|
||||||
talosctl gen config {{ cluster.name }} https://{{ cluster.controlPlaneIp }}:6443 -f \
|
talosctl gen config {{ cluster.name }} https://{{ cluster.controlPlaneIp }}:6443 -f \
|
||||||
--with-secrets ${ROOT}/secrets.yaml \
|
--with-secrets {{ cluster.secretsFile }} \
|
||||||
--output-types talosconfig \
|
--output-types talosconfig \
|
||||||
-o ${CONFIGS}/{{ cluster.name }}/talosconfig
|
-o ${CONFIGS}/{{ cluster.name }}/talosconfig
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
20
tools/render
20
tools/render
@@ -83,9 +83,23 @@ def template_constructor(environment: Environment):
|
|||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
def get_loader():
|
def realpath_constructor(directory: pathlib.Path):
|
||||||
|
def inner(loader: yaml.SafeLoader, node: yaml.nodes.ScalarNode):
|
||||||
|
try:
|
||||||
|
realpath = directory.joinpath(loader.construct_scalar(node)).resolve(
|
||||||
|
strict=True
|
||||||
|
)
|
||||||
|
return str(realpath)
|
||||||
|
except Exception:
|
||||||
|
raise yaml.MarkedYAMLError("Failed to get real path", node.start_mark)
|
||||||
|
|
||||||
|
return inner
|
||||||
|
|
||||||
|
|
||||||
|
def get_loader(directory: pathlib.Path):
|
||||||
"""Add special constructors to yaml loader"""
|
"""Add special constructors to yaml loader"""
|
||||||
loader = yaml.SafeLoader
|
loader = yaml.SafeLoader
|
||||||
|
loader.add_constructor("!realpath", realpath_constructor(directory))
|
||||||
loader.add_constructor("!schematic", schematic_constructor)
|
loader.add_constructor("!schematic", schematic_constructor)
|
||||||
loader.add_constructor("!patch", template_constructor(PATCHES))
|
loader.add_constructor("!patch", template_constructor(PATCHES))
|
||||||
|
|
||||||
@@ -97,7 +111,7 @@ def get_defaults(directory: pathlib.Path, root: pathlib.Path):
|
|||||||
"""Compute the defaults from the provided directory and parents."""
|
"""Compute the defaults from the provided directory and parents."""
|
||||||
try:
|
try:
|
||||||
with open(directory.joinpath("_defaults.yaml")) as fyaml:
|
with open(directory.joinpath("_defaults.yaml")) as fyaml:
|
||||||
yml_data = yaml.load(fyaml, Loader=get_loader())
|
yml_data = yaml.load(fyaml, Loader=get_loader(directory))
|
||||||
except OSError:
|
except OSError:
|
||||||
yml_data = {}
|
yml_data = {}
|
||||||
|
|
||||||
@@ -122,7 +136,7 @@ def main():
|
|||||||
filename = str(fullname.relative_to(NODES).parent) + "/" + fullname.stem
|
filename = str(fullname.relative_to(NODES).parent) + "/" + fullname.stem
|
||||||
|
|
||||||
with open(fullname) as fyaml:
|
with open(fullname) as fyaml:
|
||||||
yml_data = yaml.load(fyaml, Loader=get_loader())
|
yml_data = yaml.load(fyaml, Loader=get_loader(fullname.parent))
|
||||||
yml_data = get_defaults(fullname.parent, NODES) | yml_data
|
yml_data = get_defaults(fullname.parent, NODES) | yml_data
|
||||||
yml_data["hostname"] = fullname.stem
|
yml_data["hostname"] = fullname.stem
|
||||||
yml_data["filename"] = filename
|
yml_data["filename"] = filename
|
||||||
|
|||||||
Reference in New Issue
Block a user