Explain host patterns: `:`, `:&`, `:!` and wildcards.
IntermediateConceptInventory
Answer
web:db— union (either group)web:&prod— intersection (in both)web:!web3— exclusionweb*— 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.
More on Inventory
What is an inventory and why does Ansible need one?BeginnerWhat are the INI and YAML inventory formats and how do they differ?BeginnerHow do you create groups of groups?BeginnerWhich connection variables can you set per host in inventory?BeginnerWhat are `group_vars` and `host_vars` directories?IntermediateHow do you define a range of hosts in an inventory?Beginner