job "consul-cluster-nomad" {
  datacenters = ["dc1"]
  type = "service"

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

    task "consul" {
      driver = "exec"
      
      config {
        command = "consul"
        args = [
          "agent",
          "-server",
          "-bootstrap-expect=3",
          "-data-dir=/opt/nomad/data/consul",
          "-client=0.0.0.0",
          "-bind=100.117.106.136",
          "-advertise=100.117.106.136",
          "-retry-join=100.116.80.94",
          "-retry-join=100.122.197.112",
          "-ui",
          "-http-port=8500",
          "-server-port=8300",
          "-serf-lan-port=8301",
          "-serf-wan-port=8302"
        ]
      }

      resources {
        cpu = 300
        memory = 512
      }

    }
  }

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

    task "consul" {
      driver = "exec"
      
      config {
        command = "consul"
        args = [
          "agent",
          "-server",
          "-bootstrap-expect=3",
          "-data-dir=/opt/nomad/data/consul",
          "-client=0.0.0.0",
          "-bind=100.116.80.94",
          "-advertise=100.116.80.94",
          "-retry-join=100.117.106.136",
          "-retry-join=100.122.197.112",
          "-ui",
          "-http-port=8500",
          "-server-port=8300",
          "-serf-lan-port=8301",
          "-serf-wan-port=8302"
        ]
      }

      resources {
        cpu = 300
        memory = 512
      }

    }
  }

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

    task "consul" {
      driver = "exec"
      
      config {
        command = "consul"
        args = [
          "agent",
          "-server",
          "-bootstrap-expect=3",
          "-data-dir=/opt/nomad/data/consul",
          "-client=0.0.0.0",
          "-bind=100.122.197.112",
          "-advertise=100.122.197.112",
          "-retry-join=100.117.106.136",
          "-retry-join=100.116.80.94",
          "-ui",
          "-http-port=8500",
          "-server-port=8300",
          "-serf-lan-port=8301",
          "-serf-wan-port=8302"
        ]
      }

      resources {
        cpu = 300
        memory = 512
      }

    }
  }
}
