Exclude hosts based on regexp contraint

What would be the proper syntax to exclude certain hosts based on their node.class?

I have nodes with node.class setup at:

special-alpha-1
special-alpha-2
special-bravo-1
special-bravo-2
special-charlie-1
special-charlie-2

I want to exclude nodes matching a certain regexp from a sysbatch job.

I want to say “match nodes which DO NOT begin with ‘special’”

I have tried with the following, but it doesn’t work:

  constraint {
    attribute = node.class
    operator  = "regexp"
    value     = "^[^(special)]"
  }

Any help would be appreciated.

Of course, the alternative is to seed the nodes with some meta and try matching on that, but before that, wanted to check here.

Hi @shantanugadgil! I just checked your regex and that looks fine: The Go Playground

Are you sure you’ve got the right attribute? Shouldn’t that be ${node.class}?

For node.class, I am using the HCL2 bare word syntax, that’s all, I can try again with the ${} syntax to check of that works.

If the exclusion were working correctly, I should be getting about 80 nodes, I keep getting only about 36 nodes.

Could something be off with the evaluation? I did find a GH issue which reported incorrect behaviour when changing constraints.

Maybe: changing constraints results in "failed to place all allocations" · Issue #12016 · hashicorp/nomad · GitHub

a minimal job definition of what I am attempting:
(btw, bare word node.class works the same as "${node.class}")

job "updater" {
  type        = "sysbatch"
  region      = "us-west-2"
  datacenters = ["us-west-2"]

  constraint {
    attribute = node.class
    operator  = "regexp"
    value     = "^[^(special)]"
  }

  group "updater" {
    task "updater" {
      driver = "raw_exec"

      config {
        command = "/usr/bin/uptime"
      }

      env {
        foo = "1"
      }

    } # task
  }   # group
}     # job