Reputation:
My inventories are defined in a modified default Ansible Hosts
file. When I specify the -i {inventory} {.yml}
, I receive an error:
ansible 2.8.0 config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/kjames/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Apr 9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
I've told Ansible where the hosts file is in ansible.cfg
, e.g.
[defaults]
inventory=buildservers-test
Actual Results:
$ ansible-playbook -i buildservers-test deploy-mxdk-tar.yaml -k --limit wbls12ex6401
[WARNING]: Unable to parse /home/kjames/ds9/playbooks/buildservers-test as an inventory source
[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: wbls12ex6401
[WARNING]: Could not match supplied host pattern, ignoring: testservers
PLAY [testservers] ***********************************************************************
skipping: no hosts matched
PLAY RECAP ****************************************************************************
Upvotes: 2
Views: 12236
Reputation: 2308
It looks like you have a problem with your inventory location, rather than the content of the file.
Since the error says /home/kjames/ds9/playbooks/buildservers-test
, and I am assuming that your inventory file is not inside in your playbooks directory.
So the command line should be something like:
$ ansible-playbook -i ../buildservers-test deploy-mxdk-tar.yaml -k --limit wbls12ex6401
with ../buildservers-test
as inventory path, or alternatively, provide the full path, instead of ../
.
Also, have a look at the proposed best practices regarding directory layout.
It is possible that this will only work, if you get rid of your playbooks
directory altogether.
Finally, if you provide the inventory as a config parameter, you don't need to specify it at the command line, and vice versa.
Again, the problem is that the inventory file is not found to begin with.
Upvotes: 2