Add dhall experiments
This commit is contained in:
parent
e7a232daeb
commit
fca829329c
8 changed files with 158 additions and 0 deletions
17
dhall/Host.dhall
Normal file
17
dhall/Host.dhall
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
let ip = ./ip.dhall
|
||||||
|
|
||||||
|
let Address = < ip : ip.Address | dhcp >
|
||||||
|
|
||||||
|
let local =
|
||||||
|
\(suffix : Natural) ->
|
||||||
|
Address.ip (ip.address "192.168.1.${Natural/show suffix}" 24)
|
||||||
|
|
||||||
|
let Host
|
||||||
|
: Type
|
||||||
|
= { name : Text, address : Address }
|
||||||
|
|
||||||
|
let host
|
||||||
|
: Text -> Address -> Host
|
||||||
|
= \(name : Text) -> \(address : Address) -> { name, address }
|
||||||
|
|
||||||
|
in {Host, Address, host, local}
|
6
dhall/Network.dhall
Normal file
6
dhall/Network.dhall
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
let IP =
|
||||||
|
{ Type = { address : Text, prefixLength : Natural }
|
||||||
|
, default.prefixLength = 24
|
||||||
|
}
|
||||||
|
|
||||||
|
in { Network }
|
17
dhall/Proxmox.dhall
Normal file
17
dhall/Proxmox.dhall
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
let ProxmoxServerConfig = { id : Natural, address : Text }
|
||||||
|
|
||||||
|
let Proxmox = < LXC : ProxmoxServerConfig | VM : ProxmoxServerConfig >
|
||||||
|
|
||||||
|
let lxc = \(id : Natural) -> \(address : Text) -> Proxmox.LXC { id, address }
|
||||||
|
|
||||||
|
let vm = \(id : Natural) -> \(address : Text) -> Proxmox.VM { id, address }
|
||||||
|
|
||||||
|
let ipAddress =
|
||||||
|
\(server : Proxmox) ->
|
||||||
|
merge
|
||||||
|
{ LXC = \(config : ProxmoxServerConfig) -> config.address
|
||||||
|
, VM = \(config : ProxmoxServerConfig) -> config.address
|
||||||
|
}
|
||||||
|
server
|
||||||
|
|
||||||
|
in { LXC = Proxmox.LXC, VM = Proxmox.VM, lxc, ipAddress }
|
18
dhall/Server.dhall
Normal file
18
dhall/Server.dhall
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
let Simple =
|
||||||
|
{ Type = { address : Text, hostnames : List Text }
|
||||||
|
, default.hostnames = [] : List Text
|
||||||
|
}
|
||||||
|
|
||||||
|
let Proxmox = ./Proxmox.dhall
|
||||||
|
|
||||||
|
let Server = < Simple : Simple | Proxmox : Proxmox >
|
||||||
|
|
||||||
|
let ipAddress =
|
||||||
|
\(server : Server) ->
|
||||||
|
merge
|
||||||
|
{ Simple = \(s : Simple) -> s.address
|
||||||
|
, Proxmox = \(s : Proxmox.Proxmox) -> Proxmox.ipAddress s
|
||||||
|
}
|
||||||
|
server
|
||||||
|
|
||||||
|
in { ipAddress }
|
36
dhall/inventory.dhall
Normal file
36
dhall/inventory.dhall
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
let ip = ./ip.dhall
|
||||||
|
|
||||||
|
let Host = ./Host.dhall
|
||||||
|
|
||||||
|
let servers = ./servers.dhall
|
||||||
|
|
||||||
|
let render =
|
||||||
|
\(host : Host.Host) ->
|
||||||
|
let domain = "sailmaker.fenix.lgbt"
|
||||||
|
|
||||||
|
let renderAddress =
|
||||||
|
\(address : Host.Address) ->
|
||||||
|
merge
|
||||||
|
{ ip = \(ip : ip.Address) -> ip.address
|
||||||
|
, dhcp = "${host.name}.${domain}"
|
||||||
|
}
|
||||||
|
address
|
||||||
|
|
||||||
|
in { ansible_host = renderAddress host.address }
|
||||||
|
|
||||||
|
in { servers.hosts
|
||||||
|
=
|
||||||
|
{ reason = render servers.reason, nomadix = render servers.nomadix }
|
||||||
|
, appliances.hosts.ipowerswitch = render servers.ipowerswitch
|
||||||
|
, virtual.hosts
|
||||||
|
=
|
||||||
|
{ pihole = render servers.pihole
|
||||||
|
, wireguard = render servers.wireguard
|
||||||
|
, lldap = render servers.lldap
|
||||||
|
, traefik = render servers.traefik
|
||||||
|
, homeassistant = render servers.homeassistant
|
||||||
|
, mqtt = render servers.mqtt
|
||||||
|
, heimdall = render servers.heimdall
|
||||||
|
}
|
||||||
|
, sailmaker.children = { servers = {}, appliances = {}, virtual = {} }
|
||||||
|
}
|
11
dhall/ip.dhall
Normal file
11
dhall/ip.dhall
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
let Address
|
||||||
|
: Type
|
||||||
|
= { address : Text, prefixLength : Natural }
|
||||||
|
|
||||||
|
let address
|
||||||
|
: Text -> Natural -> Address
|
||||||
|
= \(address : Text) ->
|
||||||
|
\(prefixLength : Natural) ->
|
||||||
|
{ address, prefixLength }
|
||||||
|
|
||||||
|
in { Address, address }
|
22
dhall/servers.dhall
Normal file
22
dhall/servers.dhall
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
let Proxmox = ./Proxmox.dhall
|
||||||
|
|
||||||
|
let Host = ./Host.dhall
|
||||||
|
|
||||||
|
let dhcp = Host.Address.dhcp
|
||||||
|
|
||||||
|
let host = Host.host
|
||||||
|
|
||||||
|
let local = Host.local
|
||||||
|
|
||||||
|
in { router = host "reason" (local 1)
|
||||||
|
, pihole = host "pihole" (local 2)
|
||||||
|
, nomadix = host "nomadix" (local 5)
|
||||||
|
, wireguard = host "wireguard" (local 6)
|
||||||
|
, lldap = host "lldap" (local 7)
|
||||||
|
, traefik = host "traefik" (local 8)
|
||||||
|
, homeassistant = host "home-assistant" (local 13)
|
||||||
|
, mqtt = host "mqtt" (local 14)
|
||||||
|
, ipowerswitch = host "ipowerswitch" (local 99)
|
||||||
|
, reason = host "reason" (local 183)
|
||||||
|
, heimdall = host "heimdall-dashboard" dhcp
|
||||||
|
}
|
31
dhall/services.dhall
Normal file
31
dhall/services.dhall
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
let ProxmoxServer = { id : Natural }
|
||||||
|
|
||||||
|
let Protocol = < HTTP | HTTPS >
|
||||||
|
|
||||||
|
let Backend =
|
||||||
|
{ Type = { protocol : Protocol, host : Text, port : Natural }
|
||||||
|
, default = { protocol = Protocol.HTTP, port = 80 }
|
||||||
|
}
|
||||||
|
|
||||||
|
let Service =
|
||||||
|
{ Type =
|
||||||
|
{ name : Text
|
||||||
|
, hostname : Optional Text
|
||||||
|
, backends : List Backend.Type
|
||||||
|
}
|
||||||
|
, default = { hostname = None Text, backends = [] : List Backend.Type }
|
||||||
|
}
|
||||||
|
|
||||||
|
let domain = "sailmaker.fenix.lgbt"
|
||||||
|
|
||||||
|
let hostname
|
||||||
|
: Text -> Text
|
||||||
|
= \(name : Text) -> "${name}.${domain}"
|
||||||
|
|
||||||
|
let services
|
||||||
|
: List Service.Type
|
||||||
|
= [ Service::{ name = "pihole", hostname = Some (hostname "pi-hole") }
|
||||||
|
, Service::{ name = "heimdall" }
|
||||||
|
]
|
||||||
|
|
||||||
|
in services
|
Loading…
Reference in a new issue