Skip to content
Latchkey

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.

ansible
[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 hosts

Common 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.

Terminal
ansible-inventory -i inventory/prod.ini --graph
ansible-playbook -i inventory/prod.ini site.yml

Fix dynamic inventory

  1. For a plugin/script inventory, confirm credentials and filters return hosts.
  2. Ensure the inventory file is checked out at the path -i references.
  3. 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →