this should be able to read the generated values from the controller

This commit is contained in:
Chris Kruining 2025-09-16 08:43:38 +02:00
parent 492e264c26
commit 3dc01cc803
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2

View file

@ -1,6 +1,16 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, roles, ... }:
let let
inherit (builtins) pathExists readFile;
controller = head (lib.attrNames roles.controller.machines or {}); controller = head (lib.attrNames roles.controller.machines or {});
# Read the controller's ip address
ipAddressPath = "${config.clan.core.settings.directory}/vars/per-machine/${controller}/k3s-ip/ip_v4";
ipAddress = if pathExists ipAddressPath then readFile ipAddressPath else null;
# Read the controller's token
tokenPath = "${config.clan.core.settings.directory}/vars/per-machine/${controller}/k3s-token/token";
token = if pathExists ipAddressPath then readFile ipAddressPath else null;
in in
{ {
config = { config = {
@ -20,8 +30,8 @@ in
k3s = { k3s = {
enable = true; enable = true;
role = "agent"; role = "agent";
token = "somehow get the token that is generated for the controller"; # config.clan.core.vars.generators.k3s-token.token.value; token = token;
serverAddr = "https://<the ip address of the controller>"; serverAddr = "https://${ipAddress}:6443";
}; };
}; };
}; };