Host filter / patterns

For the life of me I can’t figure out how to match the right hosts on my playbook like this:

app AND (production OR staging)

I tried “app:&production:staging” but ansible turns that into “(app AND production) OR staging”.
Thinking that AND “:&” binds before OR “:”, I tried this: “app:&production:app:&staging”, which doesn’t match any thing at all.

Ansible has no grouping? So how to solve this trivial issue?

The conditions are not parsed in order (its on my todo list) but
globally, so the position of &production does not currently matter and
it gets applied after all the 'ANDs'.

i see… so the only way to solve it is by creating a new group like “stage_or_production” and then filter by “app:&stage_or_production”?

my suggestion for implementing logical groups:

hosts:

  • app:&stage
  • app:&production

meaning (app AND stage) OR (app AND production)

Maybe I overlooked something…
But wouldn’t that be the same as “staging:production:&app”?

esco