--list-hosts
The flag that prints exactly which hosts a pattern selects, without connecting to any of them or running anything.
In more detail
It works with both ansible and ansible-playbook. Running it before anything destructive answers the only question that matters: which machines am I about to change. It is the cheapest safety check in Ansible.
Example
ansible production --list-hostsRelated terms
- host pattern — An expression that picks which hosts a command or play runs against, built from host names, group names and operators.
- ansible command — The command-line tool that runs a single module against a host pattern, used for ad hoc commands and quick checks.
- ansible-playbook — The command that runs a playbook, printing a banner for each play and task, a result per host, and a recap at the end.
Taught in
- The Static Inventory File — Ansible Configuration Management at Scale
- Static Inventories: Hosts, Groups And Groups Of Groups — RHCE in Ansible (EX294): Automate Red Hat Systems
- Anatomy Of A Playbook: Plays, Tasks And Modules — RHCE in Ansible (EX294): Automate Red Hat Systems
- Variables And Where They Win: group_vars, host_vars And Play Vars — RHCE in Ansible (EX294): Automate Red Hat Systems