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

  group "consul-master" {
    count = 1

    constraint {
      attribute = "${node.unique.name}"
      value = "kr-master"
    }

    network {
      port "http" {
        static = 8500
      }
      port "rpc" {
        static = 8300
      }
      port "serf_lan" {
        static = 8301
      }
      port "serf_wan" {
        static = 8302
      }
    }

    task "consul" {
      driver = "exec"

      config {
        command = "consul"
        args = [
          "agent",
          "-server",
          "-bootstrap-expect=3",
          "-data-dir=/opt/nomad/data/consul",
          "-client=100.117.106.136",
          "-bind=100.117.106.136",
          "-advertise=100.117.106.136",
          "-retry-join=100.116.80.94",
          "-retry-join=100.122.197.112",
          "-ui"
        ]
      }

      resources {
        cpu = 300
        memory = 512
      }


    }
  }

  group "consul-ash3c" {
    count = 1

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

    network {
      port "http" {
        static = 8500
      }
      port "rpc" {
        static = 8300
      }
      port "serf_lan" {
        static = 8301
      }
      port "serf_wan" {
        static = 8302
      }
    }

    task "consul" {
      driver = "exec"

      config {
        command = "consul"
        args = [
          "agent",
          "-server",
          "-bootstrap-expect=3",
          "-data-dir=/opt/nomad/data/consul",
          "-client=100.116.80.94",
          "-bind=100.116.80.94",
          "-advertise=100.116.80.94",
          "-retry-join=100.117.106.136",
          "-retry-join=100.122.197.112",
          "-ui"
        ]
      }

      resources {
        cpu = 300
        memory = 512
      }


    }
  }

  group "consul-warden" {
    count = 1

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

    network {
      port "http" {
        static = 8500
      }
      port "rpc" {
        static = 8300
      }
      port "serf_lan" {
        static = 8301
      }
      port "serf_wan" {
        static = 8302
      }
    }

    task "consul" {
      driver = "exec"

      config {
        command = "consul"
        args = [
          "agent",
          "-server",
          "-bootstrap-expect=3",
          "-data-dir=/opt/nomad/data/consul",
          "-client=100.122.197.112",
          "-bind=100.122.197.112",
          "-advertise=100.122.197.112",
          "-retry-join=100.117.106.136",
          "-retry-join=100.116.80.94",
          "-ui"
        ]
      }

      resources {
        cpu = 300
        memory = 512
      }


    }
  }
}