How to implement many-to-many constraint?

Imagine the following Nomad cluster:

  • there is node A with metadata “groups”: “group1,group2,group3”
  • there is node B with metadata “groups”: “group2,group3,group4”
  • there is node C with metadata “groups”: “group3,group4,group5”
  • there is node D with metadata “groups”: “group4,group5,group6”

The groupX groups are just example names and can be almost any normal characters.

Now I want to run my job on nodes in group1 and group2 and group6. So something along:

constraint {
  attribute = "${meta.groups}"
  operator = "set_contains_any_from_set"
  value = "group1,group2,group6"

However, imaginary set_contains_any_from_set does not exist. The operator set_contains_any allows choosing one value from a set of value (one-to-many).

With regexp I think could write a convoluted regex to match it if lookarounds were supported. However, the page Syntax · google/re2 Wiki · GitHub lists (?=re) as (NOT SUPPORTED). My only idea forward is to simplify the list itself, so that it is possible to write a regex for it, for example tags=,group1,group2,group3, and then match with (,group1,|,group2,|,group3,).

Is it possible to match any from many-to-many in a constraint?