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

  group "consul-client-hcp1" {
    constraint {
      attribute = "${node.unique.name}"
      value     = "hcp1"
    }

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

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

      config {
        command = "/usr/bin/consul"
        args = [
          "agent",
          "-data-dir=/opt/consul",
          "-node=hcp1",
          "-bind=100.97.62.111",
          "-advertise=100.97.62.111",
          "-retry-join=hcp1.tailnet-68f9.ts.net:80",
          "-client=0.0.0.0",
          "-http-port=8500",
          "-datacenter=dc1"
        ]
      }

      resources {
        cpu    = 100
        memory = 128
      }

      service {
        name = "consul-client"
        port = "http"
        
        check {
          type     = "script"
          command  = "consul"
          args     = ["members"]
          interval = "10s"
          timeout  = "3s"
        }
      }
    }
  }

  group "consul-client-influxdb1" {
    constraint {
      attribute = "${node.unique.name}"
      value     = "influxdb1"
    }

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

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

      config {
        command = "/usr/bin/consul"
        args = [
          "agent",
          "-data-dir=/opt/consul",
          "-node=influxdb1",
          "-bind=100.100.7.4",
          "-advertise=100.100.7.4",
          "-retry-join=hcp1.tailnet-68f9.ts.net:80",
          "-client=0.0.0.0",
          "-http-port=8500",
          "-datacenter=dc1"
        ]
      }

      resources {
        cpu    = 100
        memory = 128
      }

      service {
        name = "consul-client"
        port = "http"
        
        check {
          type     = "script"
          command  = "consul"
          args     = ["members"]
          interval = "10s"
          timeout  = "3s"
        }
      }
    }
  }

  group "consul-client-browser" {
    constraint {
      attribute = "${node.unique.name}"
      value     = "browser"
    }

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

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

      config {
        command = "/usr/bin/consul"
        args = [
          "agent",
          "-data-dir=/opt/consul",
          "-node=browser",
          "-bind=100.116.112.45",
          "-advertise=100.116.112.45",
          "-retry-join=hcp1.tailnet-68f9.ts.net:80",
          "-client=0.0.0.0",
          "-http-port=8500",
          "-datacenter=dc1"
        ]
      }

      resources {
        cpu    = 100
        memory = 128
      }

      service {
        name = "consul-client"
        port = "http"
        
        check {
          type     = "script"
          command  = "consul"
          args     = ["members"]
          interval = "10s"
          timeout  = "3s"
        }
      }
    }
  }
}
