I know Ansible has issues running on windows. Which is why, I want to avoid using it for my host. I want to provision a local linux vm running in VirtualBox.
I was wondering if anyone can tell me if it is possible, to use vagrant to bring up two independent VMs on the same box. Then install Ansible on one of those VMs, then using SSH log into that VM. From there, use the Linux VM with Ansible as the host, to provision another Linux VM, that was created via the windows host machine. So, this is not a VM inside a VM. It is just two VMs running on windows using vagrant, then SSH to one of those VMs to use Ansible to provision the other VM.
Steps:
- Vagrant VM 1 and install Ansible
- Vangrant VM 2
- SSH to VM 1
- Use Ansible to provision VM 2 using VM 1.
Can that be done? Sorry if that sounded confusing.
In order to provision a box you don't necessary need to do it using another box, in this windows scenario you could simply write your playbooks, share it to your guest and hit it with
ansible-playbook
usingshell
provisioning.The first lines will get ansible on your box then it will target the playbook that you have shared to your box and run the playbooks.
This is an example, I once used this approach to provision my working vagrant box, hope this idea can help you.
There is now a new Ansible local provisioner in Vagrant 1.8.0, which you can use in your scenario.
Especially, look at "Tips and Tricks" section of the documentation, there is an exact solution (which worked for me).
Below is my Vagrantfile for this scenario (slightly different from the one in the documentation), which also solves potential problems with the ssh permissions and "executable" inventory file (if you're using Cygwin):
and inventory file: