variable "config_data" { type = string description = "Plain text config file for blocky" } job "blocky" { datacenters = ["dc1"] type = "service" priority = 100 constraint { distinct_hosts = true } update { max_parallel = 1 auto_revert = true min_healthy_time = "60s" healthy_deadline = "5m" } group "blocky" { # TODO: This must be updated to match the nubmer of servers (possibly grabbed from TF) # I am moving away from `system` jobs because of https://github.com/hashicorp/nomad/issues/12023 count = 3 network { mode = "bridge" port "dns" { static = "53" } port "api" { %{~ if use_wesher ~} host_network = "wesher" %{~ endif ~} to = "4000" } dns { # Set expclicit DNS servers because tasks, by default, use this task servers = [ "192.168.2.1", ] } } service { name = "blocky-dns" provider = "nomad" port = "dns" } service { name = "blocky-api" provider = "nomad" port = "api" tags = [ "prometheus.scrape", "traefik.enable=true", "traefik.http.routers.blocky-api.entryPoints=websecure", ] check { name = "api-health" port = "api" type = "http" path = "/" interval = "10s" timeout = "3s" check_restart { limit = 3 grace = "5m" } } } task "blocky" { driver = "docker" config { image = "ghcr.io/0xerr0r/blocky:v0.24" args = ["-c", "$${NOMAD_TASK_DIR}/config.yml"] ports = ["dns", "api"] } action "refresh-lists" { command = "/app/blocky" args = ["lists", "refresh"] } action "healthcheck" { command = "/app/blocky" args = ["healthcheck"] } resources { cpu = 50 memory = 75 memory_max = 150 } template { data = var.config_data destination = "$${NOMAD_TASK_DIR}/config.yml" splay = "1m" wait { min = "10s" max = "20s" } } template { data = <