Some checks failed
Build_Deploy / build (push) Successful in 3m40s
Build_Deploy / linter (push) Successful in 5m19s
Build_Deploy / deploy_dns (push) Failing after 2m59s
Build_Deploy / deploy_active (active) (push) Has been skipped
Build_Deploy / deploy_active (active-core) (push) Has been skipped
Build_Deploy / deploy_active (active-ext) (push) Has been skipped
This is done by letting each server manage its own network interface.
98 lines
2.1 KiB
Nix
98 lines
2.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
with lib; let
|
|
# root service
|
|
cfg = config.services.skynet;
|
|
in {
|
|
imports = [
|
|
# every server needs to have a dns record
|
|
./dns/dns.nix
|
|
|
|
# every server should have proper certs
|
|
./acme.nix
|
|
./nginx.nix
|
|
|
|
# every server may need the firewall config stuff
|
|
./firewall.nix
|
|
|
|
# every server needs teh ldap client for admins
|
|
./ldap/client.nix
|
|
|
|
# every server will need the config to backup to
|
|
./restic.nix
|
|
|
|
# every server will be monitored for grafana
|
|
./prometheus.nix
|
|
];
|
|
|
|
options.services.skynet = {
|
|
# since we use this basically everywhere provide a standard way to set it
|
|
host = {
|
|
ip = mkOption {
|
|
type = types.str;
|
|
};
|
|
name = mkOption {
|
|
type = types.str;
|
|
};
|
|
hostname = mkOption {
|
|
type = types.str;
|
|
default = "${cfg.host.name}.skynet.ie";
|
|
};
|
|
interface = mkOption {
|
|
type = types.str;
|
|
description = "Will most likely be ``eno1`` for physical servers.";
|
|
default = "eth0";
|
|
};
|
|
cidr = mkOption {
|
|
type = types.int;
|
|
description = "Most of our servers are /26, ";
|
|
default = 26;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = {
|
|
services.skynet.dns.records = [
|
|
{
|
|
record = cfg.host.name;
|
|
r_type = "A";
|
|
value = cfg.host.ip;
|
|
server = true;
|
|
}
|
|
{
|
|
record = cfg.host.ip;
|
|
r_type = "PTR";
|
|
value = cfg.host.hostname;
|
|
}
|
|
];
|
|
|
|
# set
|
|
networking = {
|
|
hostName = cfg.host.name;
|
|
defaultGateway.interface = lib.mkForce cfg.host.interface;
|
|
|
|
# needs to have an address statically assigned
|
|
interfaces."${cfg.host.interface}".ipv4.addresses = [
|
|
{
|
|
address = cfg.host.ip;
|
|
prefixLength = cfg.host.cidr;
|
|
}
|
|
];
|
|
};
|
|
|
|
services.nginx = {
|
|
virtualHosts = {
|
|
# for every server unless explisitly defined redirect the ip to skynet.ie
|
|
"${cfg.host.ip}" = {
|
|
forceSSL = true;
|
|
useACMEHost = "skynet";
|
|
locations."/".return = "307 https://skynet.ie";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|