How do I get Nomad agents to pick ip the IP of a specific network interface v1.0.1

I am using vagrant to set up my lab and vagrant assigns 10.0.2.15 to eth0 on all three of my VMs. When I go into the Nomad GUI I see the job and click the link but it is not the host IP but rather the above address and the link does not work. Currently my IP addresses go from 192.168.1.18-20. Below are my configs for the single server and the two agents. I am a novice in Vagrant and Nomad so I need someone to break it down Barney style please.

Server: ip 192.168.1.18
/etc/nomad.d/nomad.hcl
datacenter = "dc1"
data_dir = "/opt/nomad"

/etc/nomad.d/server.hcl
server {
  enabled = true
  bootstrap_expect = 1
}
advertise {
  http = "192.168.1.18:4646"
  rpc  = "192.168.1.18:4647"
  serf = "192.168.1.18:4648"
}

Agents:
/etc/nomad.d/nomad.hcl
datacenter = "dc1"
data_dir = "/opt/nomad"
bind_addr = "192.168.1.19"

/etc/nomad.d/client.hcl
client {
  enabled = true
  servers = ["192.168.1.18"]
}</code>

The job that I ran is the example from you guys.

<code>job "docs" {
  datacenters = ["dc1"]

  group "example" {
    task "server" {
      driver = "docker"

      config {
        image = "hashicorp/http-echo"

        args = [
          "-listen",
          ":5678",
          "-text",
          "hello world",
        ]
      }

      resources {
        network {
          mbits = 10

          port "http" {
            static = "5678"
          }
        }
      }
    }
  }
}

This is working for Consul and should work for Nomad, too.

"{{ GetInterfaceIP \"eth0\" }}" 

Replacing eth0 with your interface name.

does that go into the /etc/nomad.d/client.hcl?

I only knew it from there. For the job file there should be an equivalent.

I put this into one of my clients in the nomad.hcl file

bind_addr = "{{ GetInterfaceIP \"eth1\" }}" 

I left the other client with a hard coded IP address. In the GUI they both have their respective IP addresses, all good. But when I go to create a job and add

constraint {
           attribute = "${attr.nomad.advertise.address}"
           value = "IP ADDRESS FOR NODE WITH ABOVE GO template"
         }

It does not schedule it on that client. If I change the address to the hardcoded client, it schedules it on that client no problem.

Have you tried using

${attr.unique.network.ip-address}

instead?

Shameless plug: :grinning_face_with_smiling_eyes:

checkout the following:

you will have to fill in values marked inside @@...@@ with your own values depending on your server/client configuration.