Compare commits

...

1 commit

Author SHA1 Message Date
c009df2813
Initial commit -- Talos PXE Bootstrap scripts
Takes talhelper `talconfig.yaml` and downloads the assets, then
generates ignition and matchbox configuration based on your machines
defined in `talconfig.yaml`.
2024-08-21 16:33:35 -05:00
4 changed files with 81 additions and 0 deletions

View file

@ -0,0 +1,41 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.mySystem.services.talos.bootstrapAssets;
download-undionly = pkgs.writeShellScript "download-undionly" import ./resources/download-undionly.sh;
in
{
options.mySystem.services.talos.bootstrapAssets = {
enable = mkEnableOption "talos.bootstrapAssets";
bootAsset = mkOption {
type = types.str;
example = "http://10.1.1.57:8086/boot.ipxe";
};
tftpRoot = mkOption {
type = types.str;
example = "/srv/tftp";
};
matchboxDataPath = mkOption {
type = types.str;
example = "/var/lib/matchbox";
};
matchboxAssetPath = mkOption {
type = types.str;
example = "/var/lib/matchbox/assets";
};
talosSchematicIds = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "22b1d04da881ef7c57edb0f24d1f3ba2c78a8e22cbe3fa9af4f42d487b2863f7" ];
};
talhelperConfig = mkOption {
type = types.str;
example = "/etc/talhelper/config.yaml";
};
};
config = mkIf cfg.enable {
# nix grab talconfig.yaml from git repo
#
};
}

View file

@ -0,0 +1,35 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p cacert curl --pure
#shellcheck shell=bash
set -eu -o pipefail
# Check if argument $1 is set
if [ -z "${1:-}" ]; then
echo "Usage: $0 <path>"
exit 1
fi
path="$1"
# Check is file exists and exit with success.
if [ -f "$path/undionly.kpxe" ]; then
echo "File $path/undionly.kpxe already exists."
exit 0
fi
echo "Downloading assets to $path"
# Check if the directory exists
if [ ! -d "$(dirname "$path")" ]; then
echo "Error: "$path" does not exist."
exit 1
fi
# Check if the path is writable
if [ ! -w "$path" ]; then
echo "Error: $path is not writable."
exit 1
fi
# Download the file
curl -o "$path/undionly.kpxe" http://boot.ipxe.org/undionly.kpxe

View file

@ -0,0 +1,5 @@
{
imports = [
./bootstrapAssets
];
}