Ansible + Vagrant question please

56 views
Skip to first unread message

Sargon

unread,
Jun 29, 2016, 4:16:16 PM6/29/16
to Ansible Project

I want to create a Virtualbox VM and provision it.

Now I can run:

vagrant init bento/centos-6.7; vagrant up --provider virtualbox

And it's there. 

I can put this command as a local command in Ansible, but I gather there is a Vagrant module as well, which is probably more involved.

Is there a good reason why I should grok the Vagrant module to do this when a simple command will do? 

I prefer that it looks more professional and robust, and not so "hacky" but simple is good. 

Thanks

Sam Darwin

unread,
Jul 3, 2016, 11:41:07 AM7/3/16
to Ansible Project

Test Kitchen is a great way to test virtualbox instances, and here is an ansible provisioner: https://github.com/neillturner/kitchen-ansible
That will both launch and provision the machine.

Or, configure ansible directly in Vagrant: http://docs.ansible.com/ansible/guide_vagrant.html . In this case, you would still need to start and stop the vm, as you had written.

Joaquin Menchaca

unread,
Jul 5, 2016, 4:25:37 PM7/5/16
to Ansible Project
For single machine, Vagrant's built in ansible provisioner is good.  For multi-machine, you could consider using the dynamic inventory (slooow), or better, just source a configuration file (json, yaml, csv, ini, whatever) from the Vagrantfile and from a dynamic inventory.

I created some example scenarios where, Vagrant, Shell Scripts, and Ansible dynamic inventory from a config file (one source of truth):
The only draw back, is that it doesn't reflect current state of the systems (that they are running), only that they are configured to run, and how to access them through Vagrant's private key.


Reply all
Reply to author
Forward
0 new messages