job "consul-clients-dedicated" {
  datacenters = ["dc1"]
  type = "service"

  constraint {
    attribute = "${node.unique.name}"
    operator  = "regexp"
    value     = "hcp1|influxdb1|browser"
  }

  group "consul-client" {
    count = 3

    update {
      max_parallel = 3
      min_healthy_time = "5s"
      healthy_deadline = "2m"
      progress_deadline = "5m"
      auto_revert = false
    }

    network {
      port "http" {
        static = 8500
      }
    }

    task "consul-client" {
      driver = "exec"

      config {
        command = "/usr/bin/consul"
        args = [
          "agent",
          "-data-dir=/opt/consul",
          "-node=${node.unique.name}",
          "-bind=${attr.unique.network.ip-address}",
          "-advertise=${attr.unique.network.ip-address}",
          "-retry-join=warden.tailnet-68f9.ts.net:8301",
          "-retry-join=ch4.tailnet-68f9.ts.net:8301", 
          "-retry-join=ash3c.tailnet-68f9.ts.net:8301",
          "-client=0.0.0.0",
          "-http-port=${NOMAD_PORT_http}",
          "-datacenter=dc1"
        ]
      }

      resources {
        cpu    = 100
        memory = 128
      }

      service {
        name = "consul-client"
        port = "http"
        
        check {
          type     = "http"
          path     = "/v1/status/leader"
          interval = "10s"
          timeout  = "3s"
        }
      }
    }
  }
}