homelab/nomad-job/system/pihole.nomad

136 lines
3.0 KiB
Plaintext
Raw Normal View History

2022-04-03 18:45:50 +00:00
job "pihole" {
datacenters = ["homelab"]
2022-10-29 08:40:01 +00:00
priority = 100
2022-10-17 19:44:55 +00:00
meta {
force = 1
}
2022-04-03 18:45:50 +00:00
type = "service"
2022-10-29 08:40:01 +00:00
constraint {
2022-11-27 10:09:50 +00:00
attribute = "${attr.cpu.arch}"
value = "amd64"
2022-04-03 18:45:50 +00:00
}
2024-02-21 18:03:31 +00:00
constraint {
attribute = "${node.class}"
operator = "set_contains"
value = "cluster"
}
2022-10-29 08:40:01 +00:00
group "pi-hole" {
2022-04-03 18:45:50 +00:00
network {
port "dns" {
2022-10-29 08:40:01 +00:00
static = 53
2022-04-03 18:45:50 +00:00
}
port "http" {
}
}
2022-11-27 10:09:50 +00:00
2022-04-03 18:45:50 +00:00
service {
2022-10-29 08:40:01 +00:00
name = "pihole-gui"
tags = ["pihole", "admin",
"homer.enable=true",
"homer.name=Pi-hole",
"homer.service=Application",
"homer.type=PiHole",
2023-11-05 10:58:07 +00:00
"homer.logo=http://192.168.1.4:${NOMAD_PORT_http}/admin/img/logo.svg",
2022-10-29 08:40:01 +00:00
"homer.target=_blank",
2023-11-05 10:58:07 +00:00
"homer.url=http://192.168.1.4:${NOMAD_PORT_http}/admin",
2022-05-23 19:44:34 +00:00
2022-10-29 08:40:01 +00:00
]
port = "http"
2022-04-03 18:45:50 +00:00
}
task "server" {
driver = "docker"
2022-11-27 10:09:50 +00:00
service {
name = "dns"
port = "dns"
}
2022-04-03 18:45:50 +00:00
config {
2024-03-17 17:58:24 +00:00
image = "docker.service.consul:5000/pihole/pihole:2023.10.0"
2022-11-27 10:09:50 +00:00
network_mode = "host"
2022-10-29 08:40:01 +00:00
volumes = [
"local/dnsmasq.d/02-localresolver.conf:/etc/dnsmasq.d/02-localresolver.conf",
"/mnt/diskstation/nomad/pihole:/etc/pihole"
2022-04-03 18:45:50 +00:00
]
}
2022-10-29 08:40:01 +00:00
vault {
2022-10-30 08:33:39 +00:00
policies = ["pihole"]
2022-04-03 18:45:50 +00:00
2022-10-29 08:40:01 +00:00
}
env {
TZ = "Europe/Paris"
2023-11-06 18:07:04 +00:00
DNS1 = "192.168.1.5"
DNS2 = "192.168.1.40"
2022-11-27 10:09:50 +00:00
WEB_PORT = "${NOMAD_PORT_http}"
2022-04-03 18:45:50 +00:00
2022-10-29 08:40:01 +00:00
}
template {
data = <<EOH
2022-11-27 10:09:50 +00:00
INTERFACE = {{ sockaddr "GetPrivateInterfaces | include \"network\" \"192.168.1.0/24\" | attr \"name\"" }}
2023-11-05 10:58:07 +00:00
FTLCONF_LOCAL_IPV4 = 192.168.1.4
2022-10-30 08:33:39 +00:00
WEBPASSWORD="{{with secret "secrets/data/nomad/pihole"}}{{.Data.data.WEBPASSWORD}}{{end}}"
2022-04-03 18:45:50 +00:00
EOH
destination = "local/file.env"
2022-10-15 08:48:39 +00:00
change_mode = "noop"
2022-04-03 18:45:50 +00:00
env = true
2022-10-29 08:40:01 +00:00
}
template {
data = <<EOH
2022-05-17 18:59:11 +00:00
{{range service "consul"}}server=/consul/{{.Address}}#8600
{{end}}
2023-11-05 18:08:17 +00:00
domain=ducamps.eu
2022-05-28 14:01:01 +00:00
no-negcache
2023-11-05 10:58:07 +00:00
listen-address=192.168.1.4
bind-interfaces
2022-05-17 18:59:11 +00:00
local-ttl=2
2022-04-03 18:45:50 +00:00
EOH
2022-10-29 08:40:01 +00:00
destination = "local/dnsmasq.d/02-localresolver.conf"
2022-05-17 18:59:11 +00:00
change_mode = "restart"
2022-04-03 18:45:50 +00:00
}
2022-05-12 09:36:04 +00:00
resources {
2022-11-27 10:09:50 +00:00
memory = 100
2024-11-09 09:23:42 +00:00
memory_max =200
2022-11-27 10:09:50 +00:00
}
}
task "keepalived" {
driver = "docker"
lifecycle {
hook = "poststart"
sidecar = true
}
env {
KEEPALIVED_ROUTER_ID = "53"
KEEPALIVED_STATE = "MASTER"
KEEPALIVED_VIRTUAL_IPS = "192.168.1.4"
}
template{
destination = "local/env.yaml"
change_mode = "restart"
env= true
data = <<EOH
KEEPALIVED_INTERFACE= {{ sockaddr "GetPrivateInterfaces | include \"network\" \"192.168.1.0/24\" | attr \"name\"" }}
EOH
}
config {
image = "osixia/keepalived:2.0.20"
network_mode = "host"
cap_add = [
"NET_ADMIN",
"NET_BROADCAST",
"NET_RAW"
]
}
resources {
cpu = 20
memory = 20
2022-05-12 09:36:04 +00:00
}
2022-04-03 18:45:50 +00:00
}
2022-11-27 10:09:50 +00:00
2022-04-03 18:45:50 +00:00
}
}