Interview Prep/Ansible/Inventory and Targeting

A host appears in `ansible-inventory --list` but is not matched by `hosts: webservers`. What do you check?

IntermediateScenarioInventory and Targeting
Answer

Situation read → A pattern or group-name mismatch.

What I'd do →

  1. ansible-inventory --graph to see the real group tree.
  2. ansible webservers --list-hosts to test the pattern.
  3. Check for typos, case (Webservers differs from webservers), and for groups with hyphens (use underscores).

Why → Group names are case-sensitive, and a host can be present in all but in no matching group.

Interview tip → Ansible warns "Could not match supplied host pattern" for a mistyped group; never ignore it.

All Ansible questions Roadmap: Ansible

More on Inventory and Targeting