Refactor deploy logic

This commit is contained in:
asonix 2023-02-19 13:44:26 -06:00
parent c7d8386d40
commit 818dc301fa

133
flake.nix
View file

@ -653,104 +653,39 @@
};
};
deploy.nodes.redtail1 = deployer {
hostname = "192.168.20.23";
configuration = self.nixosConfigurations.redtail1;
};
deploy.nodes.whitestorm2 = deployer {
hostname = "192.168.20.27";
configuration = self.nixosConfigurations.whitestorm2;
};
deploy.nodes.garage1 = deployer {
hostname = "192.168.20.21";
configuration = self.nixosConfigurations.garage1;
};
deploy.nodes.garage2 = deployer {
hostname = "192.168.20.28";
configuration = self.nixosConfigurations.garage2;
};
deploy.nodes.garage3 = deployer {
hostname = "192.168.20.29";
configuration = self.nixosConfigurations.garage3;
};
deploy.nodes.build2 = deployer {
hostname = "192.168.20.101";
configuration = self.nixosConfigurations.build2;
};
deploy.nodes.k3s1 = deployer {
hostname = "192.168.20.120";
configuration = self.nixosConfigurations.k3s1;
};
deploy.nodes.k3s2 = deployer {
hostname = "192.168.20.121";
configuration = self.nixosConfigurations.k3s2;
};
deploy.nodes.k3s3 = deployer {
hostname = "192.168.20.122";
configuration = self.nixosConfigurations.k3s3;
};
deploy.nodes.k3s4 = deployer {
hostname = "192.168.20.123";
configuration = self.nixosConfigurations.k3s4;
};
deploy.nodes.k3s5 = deployer {
hostname = "192.168.20.124";
configuration = self.nixosConfigurations.k3s5;
};
deploy.nodes.k3s6 = deployer {
hostname = "192.168.20.125";
configuration = self.nixosConfigurations.k3s6;
};
deploy.nodes.k3s-rock1 = deployer {
hostname = "192.168.20.20";
configuration = self.nixosConfigurations.k3s-rock1;
};
deploy.nodes.k3s-rock2 = deployer {
hostname = "192.168.20.111";
configuration = self.nixosConfigurations.k3s-rock2;
};
deploy.nodes.k3s-rock3 = deployer {
hostname = "192.168.20.112";
configuration = self.nixosConfigurations.k3s-rock3;
};
deploy.nodes.k3s-rock4 = deployer {
hostname = "192.168.20.113";
configuration = self.nixosConfigurations.k3s-rock4;
};
deploy.nodes.k3s-rock5 = deployer {
hostname = "192.168.20.114";
configuration = self.nixosConfigurations.k3s-rock5;
};
deploy.nodes.k3s-rock6 = deployer {
hostname = "192.168.20.115";
configuration = self.nixosConfigurations.k3s-rock6;
};
deploy.nodes.k3s-quartza1 = deployer {
hostname = "192.168.20.160";
configuration = self.nixosConfigurations.k3s-quartza1;
};
deploy.nodes.k3s-rockpro1 = deployer {
hostname = "192.168.20.180";
configuration = self.nixosConfigurations.k3s-rockpro1;
};
deploy.nodes =
let
nodes = [
{ name = "redtail1"; ip = "192.168.20.23"; }
{ name = "whitestorm2"; ip = "192.168.20.27"; }
{ name = "garage1"; ip = "192.168.20.21"; }
{ name = "garage2"; ip = "192.168.20.28"; }
{ name = "garage3"; ip = "192.168.20.29"; }
{ name = "build2"; ip = "192.168.20.101"; }
{ name = "k3s1"; ip = "192.168.20.120"; }
{ name = "k3s2"; ip = "192.168.20.121"; }
{ name = "k3s3"; ip = "192.168.20.122"; }
{ name = "k3s4"; ip = "192.168.20.123"; }
{ name = "k3s5"; ip = "192.168.20.124"; }
{ name = "k3s6"; ip = "192.168.20.125"; }
{ name = "k3s-rock1"; ip = "192.168.20.20"; }
{ name = "k3s-rock2"; ip = "192.168.20.111"; }
{ name = "k3s-rock3"; ip = "192.168.20.112"; }
{ name = "k3s-rock4"; ip = "192.168.20.113"; }
{ name = "k3s-rock5"; ip = "192.168.20.114"; }
{ name = "k3s-rock6"; ip = "192.168.20.115"; }
{ name = "k3s-quartza1"; ip = "192.168.20.160"; }
{ name = "k3s-rockpro1"; ip = "192.168.20.180"; }
];
in
builtins.foldl'
(acc: { name, ip }: acc // {
${name} = deployer {
hostname = ip;
configuration = self.nixosConfigurations.${name};
};
})
{ }
nodes;
};
}