Fix Ansible "No hosts matched" / Skipping: No Match Found
By Luca Berton · Published 2024-01-01 · Category: troubleshooting
How to fix Ansible "no hosts matched" error. Troubleshoot inventory issues, host patterns, group names, and limit filters. Complete diagnosis guide.
Fix Ansible "No hosts matched" / Skipping: No Match Found
When Ansible says "skipping: no hosts matched", your play's hosts: pattern doesn't match any hosts in the inventory. Here's how to fix it.
Common Causes
1. Wrong Group Name
2. No Inventory Specified
3. --limit Filters Everything Out
4. Wrong Inventory Format
Debugging Steps
FAQ
Why does Ansible skip my play with "no hosts matched"?
The hosts: value in your play doesn't match any host or group in the current inventory. Check the group name, inventory file path, and any --limit filters.
How do I list all hosts in my inventory?
Run ansible all -i inventory.ini --list-hosts or ansible-inventory -i inventory.ini --list for a detailed view including variables.
Can I make Ansible fail instead of skip when no hosts match?
No built-in option, but you can add a pre-check task on localhost that verifies the target group is not empty using groups['mygroup'] | default([]) | length > 0.
Related Articles • Ansible Inventory: Complete Guide • Ansible Playbook Guide
Category: troubleshooting