Interview Prep/Ansible/Connection and SSH Failures

`ERROR! Specified inventory, inventory directory, or script does not exist` / `[WARNING]: provided hosts list is empty, only localhost is available`

BeginnerTroubleshootingConnection and SSH Failures
Answer

Likely causes → Wrong -i path, wrong working directory, or inventory = missing from ansible.cfg; a trailing comma is needed for a one-off host list.

Diagnose →

ansible --version | grep 'config file'
ansible-inventory -i inventory.ini --graph

Fix → Fix the path, or use -i 'web01,' (with the comma) for a single host.

Prevent → Set inventory in a checked-in ansible.cfg.

All Ansible questions Roadmap: Ansible

More on Connection and SSH Failures