Add fs0 cluster to new deployment infra

This commit is contained in:
Jonas Juselius
2019-02-23 16:11:21 +01:00
parent 20e584d767
commit 7b59038e50
4 changed files with 32 additions and 14 deletions

2
fs0/build.nix Normal file
View File

@@ -0,0 +1,2 @@
with import <nixpkgs> {};
pkgs.callPackage ./certs.nix {}

11
fs0/certs.nix Normal file
View File

@@ -0,0 +1,11 @@
{ pkgs, ...}:
let
pki = pkgs.callPackage ../lib/pki.nix {};
in
{
initca = pki.initca;
ca = pki.ca;
fs0-0 = pki.trust "fs0-0" ''"10.253.18.106", "127.0.0.1"'';
fs0-1 = pki.trust "fs0-1" ''"10.1.2.164", "127.0.0.1"'';
}

View File

@@ -1,20 +1,21 @@
with import <nixpkgs> {}; with import <nixpkgs> {};
let let
pki = pkgs.callPackage ./lib/pki.nix {}; pki = pkgs.callPackage ../lib/pki.nix {};
certs = pkgs.callPackage ./certs.nix {};
clusterHosts = '' clusterHosts = ''
10.253.18.106 fs0-0 fs0-0.local 10.253.18.106 fs0-0 fs0-0.local
10.1.2.164 fs0-1 fs0-1.local 10.1.2.164 fs0-1 fs0-1.local
10.253.18.100 fs0-2 fs0-2.local 10.253.18.100 fs0-2 fs0-2.local
''; '';
nixosConfig = node: ip: nixosConfig = node:
let let
cert = pki.trust node ''"${node}", "${ip}", "127.0.0.1"''; cert = pki.toSet certs.${node};
in in
{ {
imports = [ imports = [
(./nixos/hardware-configuration + "/${node}.nix") (../nixos/hardware-configuration + "/${node}.nix")
./nixos/configuration.nix ../nixos/configuration.nix
]; ];
boot.kernelModules = [ boot.kernelModules = [
"dm_snapshot" "dm_snapshot"
@@ -42,7 +43,7 @@ in
{ {
fs0-0 = { ... }: fs0-0 = { ... }:
let let
base = nixosConfig "fs0-0" "10.253.18.106"; base = nixosConfig "fs0-0";
in in
{ {
deployment.targetHost = "10.253.18.106"; deployment.targetHost = "10.253.18.106";
@@ -58,7 +59,7 @@ in
}; };
fs0-1 = { ... }: fs0-1 = { ... }:
let let
base = nixosConfig "fs0-1" "10.1.2.164"; base = nixosConfig "fs0-1";
in in
{ {
deployment.targetHost = "10.1.2.164"; deployment.targetHost = "10.1.2.164";

View File

@@ -112,10 +112,14 @@
}; };
}; };
trust = name: hosts: gencert rec { trust = name: hosts:
let
hosts' = "\"${name}\", " + hosts;
in gencert rec {
inherit name; inherit name;
csr = gencsr { csr = gencsr {
inherit name hosts; inherit name;
hosts = hosts';
cn = name; cn = name;
o = name; o = name;
}; };