I have set up a machine with Vagrant, and created a basic Ansible playbook for it. Everything works as expected when I run
vm-abla> vagrant provision
As @mascip already self-answered, you need to tell ansible: inventory_file, ssh_user and ssh_private_key. (I don't think the -c ssh
setting is needed.)
The "elegant way" is to put all those settings into a project-specific ansible.cfg file. Then you can just run ansible jon -a "echo 'TEST'"
.
One "gotcha" is that ansible.cfg must be in the same directory as where you're running the ansible
command. I like to put ansible.cfg under my ansible directory, so that means I need to cd
there first. If you want to run ansible
from your project root, then put ansible.cfg there instead (and adjust the relative paths in the sample config file below).
ansible.cfg:
[defaults]
remote_user = vagrant
private_key_file = ~/.vagrant.d/insecure_private_key
# aka inventory file
hostfile = ../.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory