Explain host patterns: `:`, `:&`, `:!` and wildcards.

IntermediateConceptInventory
Answer
  • web:db — union (either group)
  • web:&prod — intersection (in both)
  • web:!web3 — exclusion
  • web* — glob on host or group names
  • ~web\d+ — a regular expression, prefixed with ~
  • web[0] / web[1:3] — index/slice into a group
ansible 'prod:&web:!web3' -m ping
ansible-playbook site.yml --limit 'web:&eu'

Quote patterns, because the shell treats ! and & specially.

All Ansible questions Roadmap: Ansible

More on Inventory