Host filter / patterns

31 views
Skip to first unread message

Bouke

unread,
Aug 21, 2015, 9:13:18 AM8/21/15
to Ansible Project
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?

Brian Coca

unread,
Aug 21, 2015, 11:12:27 AM8/21/15
to Ansible Project
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'.




--
Brian Coca

Bouke

unread,
Sep 4, 2015, 12:35:47 PM9/4/15
to Ansible Project
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)

esco real

unread,
Sep 4, 2015, 5:30:08 PM9/4/15
to Ansible Project
Maybe I overlooked something..
But wouldn't that be the same as "staging:production:&app"?

esco
Reply all
Reply to author
Forward
0 new messages