system-manager-wakasu
  1{ dns, globals, ... }:
  2with dns.lib.combinators;
  3let
  4  # Machines with home network IPs that should have wildcards
  5  machinesWithWildcard = [
  6    "okinawa"
  7    "sakhalin"
  8    "aomi"
  9    "rhea"
 10    "aion"
 11    "shikoku"
 12    "athena"
 13    "demeter"
 14    "nagoya"
 15  ];
 16
 17  mkHomeMachineRecords = builtins.listToAttrs (
 18    map (machineName: {
 19      name = machineName;
 20      value =
 21        let
 22          homeIP = globals.machines.${machineName}.net.ips;
 23          ip = if builtins.isList homeIP then builtins.head homeIP else homeIP;
 24        in
 25        {
 26          A = [ ip ];
 27          subdomains."*".A = [ ip ];
 28        };
 29    }) machinesWithWildcard
 30  );
 31in
 32{
 33  SOA = {
 34    nameServer = "ns1.home.";
 35    adminEmail = "admin.home";
 36    serial = 3;
 37    refresh = 604800;
 38    retry = 86400;
 39    expire = 2419200;
 40    minimum = 604800;
 41  };
 42
 43  NS = [
 44    "ns1.home."
 45    "ns2.home."
 46  ];
 47
 48  subdomains = {
 49    # Name servers
 50    ns1.A = [ (builtins.head globals.machines.demeter.net.ips) ];
 51    ns2.A = [ (builtins.head globals.machines.athena.net.ips) ];
 52
 53    # Cache wildcard
 54    cache.subdomains."*".A = [ (builtins.head globals.machines.sakhalin.net.ips) ];
 55
 56    # Machines without wildcards
 57    hokkaido.A = [ (builtins.head globals.machines.hokkaido.net.ips) ];
 58    synodine.A = [ (builtins.head globals.machines.synodine.net.ips) ];
 59
 60    # Hardcoded entries not in globals or incomplete in globals
 61    wakasu = {
 62      A = [ "192.168.1.77" ];
 63      subdomains."*".A = [ "192.168.1.77" ];
 64    };
 65    honshu.A = [ "192.168.1.17" ];
 66    remakrable.A = [ "192.168.1.57" ];
 67    hass.A = [ "192.168.1.181" ];
 68
 69    #   # OpenShift infrastructure
 70    #   vm0.A = [ "192.168.1.120" ];
 71    #   vm1.A = [ "192.168.1.121" ];
 72    #   vm2.A = [ "192.168.1.122" ];
 73    #   vm3.A = [ "192.168.1.123" ];
 74    #   vm4.A = [ "192.168.1.124" ];
 75    #   vm5.A = [ "192.168.1.125" ];
 76    #   vm6.A = [ "192.168.1.126" ];
 77    #   vm7.A = [ "192.168.1.127" ];
 78    #   vm8.A = [ "192.168.1.128" ];
 79    #   vm9.A = [ "192.168.1.129" ];
 80    #
 81    #   ocp = {
 82    #     subdomains = {
 83    #       api.A = [ "192.168.1.120" ];
 84    #       api-int.A = [ "192.168.1.120" ];
 85    #       apps.subdomains."*".A = [ "192.168.1.120" ];
 86    #       master0.A = [ "192.168.1.121" ];
 87    #       master1.A = [ "192.168.1.122" ];
 88    #       master3.A = [ "192.168.1.123" ];
 89    #       worker1.A = [ "192.168.1.124" ];
 90    #       worker2.A = [ "192.168.1.125" ];
 91    #       worker3.A = [ "192.168.1.126" ];
 92    #       worker4.A = [ "192.168.1.127" ];
 93    #       worker5.A = [ "192.168.1.128" ];
 94    #       bootstrap.A = [ "192.168.1.129" ];
 95    #       etcd-0.A = [ "192.168.1.121" ];
 96    #       etcd-1.A = [ "192.168.1.122" ];
 97    #       etcd-2.A = [ "192.168.1.123" ];
 98    #     };
 99    #     SRV = [
100    #       {
101    #         service = "etcd-server-ssl";
102    #         proto = "tcp";
103    #         priority = 0;
104    #         weight = 10;
105    #         port = 2380;
106    #         target = "etcd-0.ocp.home.";
107    #       }
108    #       {
109    #         service = "etcd-server-ssl";
110    #         proto = "tcp";
111    #         priority = 0;
112    #         weight = 10;
113    #         port = 2380;
114    #         target = "etcd-1.ocp.home.";
115    #       }
116    #       {
117    #         service = "etcd-server-ssl";
118    #         proto = "tcp";
119    #         priority = 0;
120    #         weight = 10;
121    #         port = 2380;
122    #         target = "etcd-2.ocp.home.";
123    #       }
124    #     ];
125    #   };
126    #
127    #   # k8s nodes
128    #   ubnt1.A = [ "192.168.1.130" ];
129    #   ubnt2.A = [ "192.168.1.131" ];
130    #   k8sn1.A = [ "192.168.1.130" ];
131    #   k8sn2.A = [ "192.168.1.131" ];
132    #   k8sn3.A = [ "192.168.1.132" ];
133  }
134  // mkHomeMachineRecords;
135}