Ansible "No inventory was parsed" in CI
Ansible found no usable hosts. The -i path is missing or empty, points at an unparseable file, or a dynamic inventory plugin returned nothing -- so only implicit localhost remains.
What this error means
ansible-playbook warns "No inventory was parsed, only the implicit localhost is available", then "Could not match supplied host pattern" or "skipping: no hosts matched". The play targets nothing.
[WARNING]: No inventory was parsed, only the implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'
ERROR! Specified hosts and/or --limit does not match any hostsCommon causes
Wrong or missing inventory path
The -i path does not exist on the runner, or the file is empty, so no hosts are parsed.
Unrecognized format or empty dynamic source
A file Ansible cannot parse as INI/YAML, or a dynamic inventory plugin returning no hosts, yields an empty inventory.
How to fix it
Point at a valid, populated inventory
Pass an explicit -i path that exists and contains hosts; verify with the inventory graph.
ansible-inventory -i inventory/prod.ini --graph
ansible-playbook -i inventory/prod.ini site.ymlFix dynamic inventory
- For a plugin/script inventory, confirm credentials and filters return hosts.
- Ensure the inventory file is checked out at the path -i references.
- Set inventory in ansible.cfg if CI omits -i.
How to prevent it
- Pass an explicit -i to a committed, populated inventory.
- Verify with ansible-inventory --graph in CI.
- Test dynamic inventory plugins return hosts before the play.