dne-dna-code
dne-dna-code copied to clipboard
Intro to Ansible Lab inventory file not found
When trying to run the lab I get errors around the inventory file/host file not being found:
ansible-playbook ansible-02-ios-modules/02-ios_command_show.yaml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: iosxe
I believe the ansible.cfg
file is incorrect.
When changed from:
[defaults]
hostfile = hosts
host_key_checking = False
deprecation_warnings=False
stdout_callback = skippy
[persistent_connection]
connect_timeout = 100
command_timeout = 80
to (changing line 2)
[defaults]
inventory = hosts
host_key_checking = False
deprecation_warnings=False
stdout_callback = skippy
[persistent_connection]
connect_timeout = 100
command_timeout = 80
all errors are solved and the playbooks run as intended.
I would create a pull request for this change but want someone to sanity check this first for me.
I think you got it right. Have checked official documentation from ansible here: https://docs.ansible.com/ansible/latest/reference_appendices/config.html They have reference to inventory, but didn't find reference to hostfile. Here is what they have on the doc. page: inventory = /etc/ansible/hosts ; This points to the file that lists your hosts
[defaults] inventory = ./hosts