Skip to content
Latchkey

Ansible "Unable to parse ... as an inventory source" in CI

Ansible tries each enabled inventory plugin against the source you pass. When none can parse it (a wrong path, bad format, or a dynamic script that errors), it warns it could not parse the source and the play matches no hosts.

What this error means

ansible-playbook prints "[WARNING]: Unable to parse /path as an inventory source" and then "Could not match supplied host pattern", running against an empty inventory.

Ansible
[WARNING]: Unable to parse /repo/inventory.ini as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available

Common causes

A wrong path or missing inventory file

The -i path does not exist in the runner checkout, so no plugin has anything valid to parse.

A malformed or non-executable dynamic inventory

An INI/YAML inventory has a format error, or a dynamic inventory script is not executable or exits non-zero.

How to fix it

Point at a valid inventory and verify it

  1. Confirm the inventory path exists in the CI workspace.
  2. List the parsed inventory with ansible-inventory to validate the format.
  3. For dynamic inventories, make the script executable and ensure it returns valid JSON.
Terminal
ansible-inventory -i inventory.ini --list
chmod +x inventory.py   # for a dynamic inventory script

Enable the matching inventory plugin

If you use a plugin-based source (YAML config), enable that plugin in ansible.cfg so it is tried.

ansible.cfg
[inventory]
enable_plugins = host_list, script, auto, yaml, ini

How to prevent it

  • Validate inventory with ansible-inventory --list in CI.
  • Use absolute or repo-relative inventory paths that exist on the runner.
  • Make dynamic inventory scripts executable and JSON-valid.

Frequently asked questions

What causes ""Unable to parse ... as an inventory source""?
The -i path does not exist in the runner checkout, so no plugin has anything valid to parse.
How do I fix "Unable to parse ... as an inventory source"?
Point at a valid inventory and verify it

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card