host pattern
An expression that picks which hosts a command or play runs against, built from host names, group names and operators.
In more detail
A group name selects the group and its children; a colon joins two selections; :! removes one; :& keeps only hosts in both; and a star is a wildcard on names. Patterns are evaluated left to right and should be quoted in the shell, because ! and & mean something to it. Check a pattern with --list-hosts before running anything that changes machines.
Example
ansible 'production:!dbservers' --list-hostsRelated terms
- group — A named set of hosts in an inventory, used both to target them together and to attach variables that are true of all of them.
- --list-hosts — The flag that prints exactly which hosts a pattern selects, without connecting to any of them or running anything.
- wildcard — A special character, such as *, that stands for any value or any run of characters when matching names or patterns.
- play — One section of a playbook that picks a set of hosts with a pattern and lists the tasks to run on them, in order.
Taught in
- Your First Ad Hoc Command — Ansible Configuration Management at Scale
- The Static Inventory File — Ansible Configuration Management at Scale
- Playbook Syntax And YAML — Ansible Configuration Management at Scale
- Check Mode And Diff — Ansible Configuration Management at Scale
- Static Inventories: Hosts, Groups And Groups Of Groups — RHCE in Ansible (EX294): Automate Red Hat Systems
- Mock Exam, Part 1: Seven Tasks Across Three Sections — RHCE in Ansible (EX294): Automate Red Hat Systems