I have a vagrant
box with precise32
up and running.
I am in ~/Workspace/vagrans/ansible
folder where there is a file ansible.cfg
with the following entries:
[defaults]
inventory = ./dms/dev
private_key_file = /home/pkaramol/Workspace/vagrans/vagrant/precise32/.vagrant/machines/default/virtualbox/private_key
This works:
ansible -m ping all --private-key=/home/pkaramol/Workspace/vagrans/vagrant/precise32/.vagrant/machines/default/virtualbox/private_key -u vagrant
tsrv1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
This doesn't:
ansible-playbook playbooks/testplay.yml
PLAY ***************************************************************************
TASK [setup] *******************************************************************
fatal: [tsrv1]: UNREACHABLE! => {"changed": false, "msg": "ERROR! SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue", "unreachable": true}
PLAY RECAP *********************************************************************
tsrv1 : ok=0 changed=0 unreachable=1 failed=0
Here is the playbook:
- hosts: testservers
tasks:
- name: just pinging
ping:
And here is the inventory file
[testservers]
tsrv1
I must be missing sth (?) ...
There is no need to split the credentials between the configuration file and the playbook like you suggested.
You can use
remote-user
parameter in theansible.cfg
next to theprivate_key_file
: