unifi/unifi.nomad.hcl

200 lines
4.1 KiB
HCL
Raw Permalink Normal View History

2024-01-22 21:47:02 +01:00
job "[[ .instance ]]" {
2023-08-22 00:12:44 +02:00
2023-12-15 15:26:58 +01:00
[[- template "common/job_start" . ]]
2023-08-22 00:12:44 +02:00
2023-08-25 00:18:53 +02:00
group "unifi" {
2023-08-22 00:12:44 +02:00
2024-01-22 21:47:02 +01:00
[[- $c := merge .unifi.controller .unifi . ]]
2024-04-26 13:36:04 +02:00
[[ template "common/group_start" $c ]]
2023-10-08 18:25:55 +02:00
2023-08-22 00:12:44 +02:00
network {
mode = "bridge"
2023-09-02 00:19:21 +02:00
port "stun" {
to = 3478
}
2023-08-22 00:12:44 +02:00
}
2023-08-23 23:16:59 +02:00
service {
2024-01-22 21:47:02 +01:00
name = "[[ .instance ]][[ .consul.suffix ]]"
2023-08-23 23:16:59 +02:00
port = 8888
2023-08-22 00:12:44 +02:00
2024-04-26 13:36:04 +02:00
[[ template "common/service_meta" $c ]]
[[ template "common/connect" $c ]]
2023-08-22 00:12:44 +02:00
2024-01-09 09:15:48 +01:00
check {
type = "http"
path = "/status"
expose = true
2024-05-12 21:31:40 +02:00
[[ template "common/check_settings" $c ]]
2024-01-09 09:15:48 +01:00
check_restart {
limit = 12
grace = "2m"
}
}
2023-08-22 00:12:44 +02:00
tags = [
2024-01-27 00:34:57 +01:00
[[ template "common/traefik_tags" $c ]]
2024-01-29 11:29:09 +01:00
[[ template "common/traefik_tags" merge .unifi.inform . ]]
[[ template "common/traefik_tags" merge .unifi.guest_portal . ]]
2023-08-22 00:12:44 +02:00
]
}
2023-08-23 23:16:59 +02:00
service {
2024-01-22 21:47:02 +01:00
name = "[[ .instance ]]-stun[[ .consul.suffix ]]"
2023-08-23 23:16:59 +02:00
port = "stun"
2023-08-22 00:12:44 +02:00
tags = [
2024-01-29 11:29:09 +01:00
[[ template "common/traefik_tags" merge .unifi.stun . ]]
2023-08-22 00:12:44 +02:00
]
}
2024-01-22 21:47:02 +01:00
[[- if not $c.mongo.is_external ]]
2023-08-23 23:16:59 +02:00
service {
2024-01-22 21:47:02 +01:00
name = "[[ .instance ]]-mongo[[ .consul.suffix ]]"
2023-08-23 23:16:59 +02:00
port = 27017
2023-08-22 00:12:44 +02:00
2024-04-26 13:36:04 +02:00
[[ template "common/service_meta" $c ]]
2023-08-23 23:16:59 +02:00
check {
type = "script"
command = "sh"
2023-12-15 15:26:58 +01:00
args = ["-c", "mongo --quiet --eval 'db.runCommand(\"ping\").ok'"]
2024-05-12 21:31:40 +02:00
task = "mongo"
2024-04-26 13:36:04 +02:00
interval = "[[ $c.consul.check.interval ]]"
timeout = "[[ $c.consul.check.timeout ]]"
2023-08-25 15:07:57 +02:00
check_restart {
limit = 4
grace = "3m"
}
2023-08-23 23:16:59 +02:00
}
2023-08-22 00:12:44 +02:00
}
2024-01-05 15:07:43 +01:00
[[ template "common/volumes" .unifi.mongo.volumes ]]
2023-08-22 00:12:44 +02:00
[[- end ]]
2024-01-22 21:47:02 +01:00
[[ template "common/volumes" $c ]]
2023-12-15 15:26:58 +01:00
[[ template "common/task.wait_for" $c ]]
2023-08-22 00:12:44 +02:00
2023-08-23 23:16:59 +02:00
task "nginx" {
2024-01-22 21:47:02 +01:00
[[- $c := merge .unifi.nginx .unifi . ]]
driver = "[[ .nomad.driver ]]"
user = 8306
2023-08-22 00:12:44 +02:00
2023-08-23 23:16:59 +02:00
lifecycle {
hook = "poststart"
sidecar = "true"
}
2023-08-22 00:12:44 +02:00
2023-08-23 23:16:59 +02:00
config {
2024-01-22 21:47:02 +01:00
image = "[[ .unifi.nginx.image ]]"
volumes = ["local/nginx.conf:/etc/nginx/conf.d/default.conf"]
readonly_rootfs = true
2024-01-27 00:34:57 +01:00
pids_limit = 20
[[ template "common/tmpfs" "/tmp" ]]
2023-08-23 23:16:59 +02:00
}
2023-08-22 00:12:44 +02:00
2023-08-23 23:16:59 +02:00
template {
data =<<_EOF
[[ template "unifi/nginx/nginx.conf.tpl" . ]]
_EOF
destination = "local/nginx.conf"
}
2024-01-22 21:47:02 +01:00
[[ template "common/resources" $c ]]
2023-08-22 00:12:44 +02:00
}
2023-08-25 00:18:53 +02:00
task "controller" {
2023-08-23 23:16:59 +02:00
2024-01-22 21:47:02 +01:00
[[ $c := merge .unifi.controller .unifi . ]]
2023-08-23 23:16:59 +02:00
leader = true
2024-01-22 21:47:02 +01:00
driver = "[[ $c.nomad.driver ]]"
2023-08-23 23:16:59 +02:00
config {
2024-01-22 21:47:02 +01:00
image = "[[ $c.image ]]"
2023-08-23 23:16:59 +02:00
volumes = [
"local/init-system.properties.sh:/entrypoint.d/10-init-system.properties.sh"
]
2024-01-22 21:47:02 +01:00
readonly_rootfs = true
2024-01-27 00:34:57 +01:00
pids_limit = 200
[[ template "common/tmpfs" "/opt/unifi/run" ]]
[[ template "common/tmpfs" "/tmp" ]]
2023-08-23 23:16:59 +02:00
}
2024-01-22 21:47:02 +01:00
[[ template "common/vault.policies" $c ]]
2023-08-31 22:43:12 +02:00
2023-08-23 23:16:59 +02:00
env {
2024-01-29 20:28:01 +01:00
TMPDIR = "/local/tmp"
2023-08-23 23:16:59 +02:00
}
2024-01-22 21:47:02 +01:00
[[ template "common/file_env" $c ]]
2023-08-23 23:16:59 +02:00
template {
data =<<_EOF
[[ template "unifi/controller/system.properties.tpl" . ]]
2023-08-22 00:12:44 +02:00
_EOF
2023-08-23 23:16:59 +02:00
destination = "secrets/system.properties"
}
template {
data =<<_EOF
[[ template "unifi/controller/init-system.properties.sh.tpl" . ]]
_EOF
destination = "local/init-system.properties.sh"
perms = "755"
}
volume_mount {
2023-10-27 00:16:04 +02:00
volume = "data"
2023-08-23 23:16:59 +02:00
destination = "/data"
}
2024-01-22 21:47:02 +01:00
[[ template "common/resources" $c ]]
2023-08-23 23:16:59 +02:00
2023-08-22 00:12:44 +02:00
}
[[- if not .unifi.controller.mongo.is_external ]]
2023-08-23 23:16:59 +02:00
task "mongo" {
2024-01-22 21:47:02 +01:00
[[- $c := merge .unifi.mongo .unifi . ]]
driver = "[[ $c.nomad.driver ]]"
2023-08-22 00:12:44 +02:00
2023-08-23 23:16:59 +02:00
lifecycle {
2023-08-25 15:07:57 +02:00
hook = "prestart"
sidecar = true
2023-08-23 23:16:59 +02:00
}
config {
2024-01-22 21:47:02 +01:00
image = "[[ $c.image ]]"
command = "mongod"
readonly_rootfs = true
2024-01-27 00:34:57 +01:00
pids_limit = 200
2024-01-22 21:47:02 +01:00
args = ["--config", "/local/mongod.conf" ]
2024-01-27 00:34:57 +01:00
[[ template "common/tmpfs" "/tmp" ]]
2023-08-23 23:16:59 +02:00
}
template {
data =<<_EOF
[[ template "unifi/mongo/mongod.conf.tpl" . ]]
_EOF
destination = "local/mongod.conf"
}
2023-08-22 00:12:44 +02:00
2023-08-23 23:16:59 +02:00
volume_mount {
volume = "mongo"
2023-08-24 11:08:39 +02:00
destination = "/data/db"
2023-08-23 23:16:59 +02:00
}
2024-01-22 21:47:02 +01:00
[[ template "common/resources" $c ]]
2023-08-23 23:16:59 +02:00
}
2023-08-22 00:12:44 +02:00
}
[[- end ]]
2023-08-22 00:12:44 +02:00
}