Repository navigation
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
61 lines (53 loc) · 2.01 KB
/
Copy pathTaskfile.yaml
File metadata and controls
61 lines (53 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
version: "3"
tasks:
kopiur:
desc: Run the repository-pinned Kopiur CLI
cmds:
- ./scripts/kopiur {{.CLI_ARGS}}
silent: true
gen:
desc: Render Talos machine and client configurations
dir: talos
preconditions:
- sh: test -f talsecret.sops.yaml
msg: The existing Talos secrets bundle is required
- sh: grep -q '^sops:' talsecret.sops.yaml
msg: Refusing to render without a SOPS-encrypted Talos secrets bundle
cmds:
- |
output_dir="$(mktemp -d)"
secrets_backup="$(mktemp)"
cp talsecret.sops.yaml "${secrets_backup}"
finish() {
status=$?
trap - EXIT
rm -rf "${output_dir}"
rm -f ./clusterconfig/*.tmp
if ! cmp -s "${secrets_backup}" talsecret.sops.yaml; then
cp "${secrets_backup}" talsecret.sops.yaml
echo "TOPF changed the Talos secrets bundle; the encrypted original was restored" >&2
status=1
fi
rm -f "${secrets_backup}"
exit "${status}"
}
trap finish EXIT
talos_version="$(awk '/^talosVersion:/ { print $2 }' topf.yaml)"
../scripts/talosctl version --client --short | grep -q "Talos ${talos_version}$"
../scripts/topf render --output "${output_dir}"
../scripts/topf talosconfig > "${output_dir}/talosconfig"
chmod 0600 "${output_dir}/talosconfig"
if ! cmp -s "${secrets_backup}" talsecret.sops.yaml; then
cp "${secrets_backup}" talsecret.sops.yaml
echo "TOPF changed the Talos secrets bundle; refusing generated output" >&2
exit 1
fi
for config in "${output_dir}"/*.yaml; do
../scripts/talosctl validate --strict --mode metal --config "${config}"
done
for config in "${output_dir}"/*; do
destination="./clusterconfig/$(basename "${config}")"
install -m 0600 "${config}" "${destination}.tmp"
mv "${destination}.tmp" "${destination}"
done
silent: false