nomad

Nomad job constraint: run on list of nodes


I'm trying to find a way to run a Nomad job on a specific set of machines identified by IP address. I have looked at the documentation on the constraint block, but I can't find a way to achieve this. Ideally, it would look something like:

job "myjob" {
  type = "sysbatch"

  constraint {
    attribute = "${attr.unique.network.ip-address}"
    operator  = "attribute_included_in"
    value     = "<ip1>,<ip2>,<ip3>"
  }

  group "sys_batch_job" {
    # ...
  }
}

The operators set_contains and set_contains_any are both intended for scenarios where the attribute itself contains a list of values. I tried using the regexp operator, but it also doesn't work. Any idea how to go about this?


Solution

  • Invert your thinking.

      constraint {
        attribute = "<ip1>,<ip2>,<ip3>"
        operator  = "set_contains"
        value     = "${attr.unique.network.ip-address}"
      }