Reputation: 31
I've put together a VM using Vagrant (Virtualbox is the provider) for a server I'm setting up. I can SSH into the VM using vagrant ssh
and ssh vmname
, but when I run ansible-playbook -vvvv /path/to/playbook.yml
, I get a "permission denied" error when Ansible tries to connect to the VM.
It's too long to post the results of running the playbook here, so I've uploaded it to Pastebin instead.
What am I doing wrong?
Upvotes: 2
Views: 1366
Reputation: 315
Did you have a ansible.cfg inside your current dir? Ansible could be using these configurations, made for another environment connection (different user, like the first answer here) and be impacting your directly connection. If so, try to hide your ansible.cfg file with:
mv ansible.cfg .ansible.cfg
Upvotes: 0
Reputation: 6006
Your playbook try connecting to the target vm with user root
but that doesn't exist in the vm.
To double-check it, I think you get an error trying to login to the VM using
ssh root@vmname
Because you are sure that the vagrant
user exists in the VM, setting remote_user
as vagrant
in /path/to/playbook.yml
should solve your problem:
remote_user: vagrant
Otherwise, you can run ansible-playbook with options -u and -k
ansible-playbook /path/to/playbook.yml -u vagrant -k
Upvotes: 1