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.
[WARNING]: Unable to parse /repo/inventory.ini as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is availableCommon 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
- Confirm the inventory path exists in the CI workspace.
- List the parsed inventory with
ansible-inventoryto validate the format. - For dynamic inventories, make the script executable and ensure it returns valid JSON.
ansible-inventory -i inventory.ini --list
chmod +x inventory.py # for a dynamic inventory scriptEnable the matching inventory plugin
If you use a plugin-based source (YAML config), enable that plugin in ansible.cfg so it is tried.
[inventory]
enable_plugins = host_list, script, auto, yaml, iniHow to prevent it
- Validate inventory with
ansible-inventory --listin CI. - Use absolute or repo-relative inventory paths that exist on the runner.
- Make dynamic inventory scripts executable and JSON-valid.