Vagrant Workflow suggestion - how to expand environment?

62 views
Skip to first unread message

Jason Williams

unread,
Jul 14, 2020, 4:47:40 PM7/14/20
to Vagrant
hello everyone.
I am starting to use Vagrant and Virtualbox more and more in my testing/development work. The more I work with the two, the more ideas and questions I have. I was hoping for some guidance/clarification and maybe best practices.
Let me start with what I am working on and what I have done.

I use NGINX quite a bit for web servers, proxying and load balancing.
I have successfully setup a multi-vagrant setup using 2 servers to serve content. Step in the right direction.

Where my question is really at is, once I spin up my Vagrant environment and start to do my testing, I see there are things that I need to change with the current boxes that I am using.
This could be things like additional software, specific configuration file settings, copying over content etc.

That all being said, is the best practices approach to then package up one of my current boxes which will contain all my changes? If that is true, what if I have I have different boxes in a multi-vagrant setup? Do i just package each one individually?
Lastly, how do I call/use these new boxes that I have created? Do i need to edit the Vagrantfile and change the speciic image being used?

This is where my rookiness to Vagrant is coming up short and was hoping the more experienced users could shed some light.

I appreciate the help!

Cheers!

.

unread,
Jul 14, 2020, 6:04:35 PM7/14/20
to vagra...@googlegroups.com
This is where Ansible  https://docs.ansible.com/  would come in to help you provision the VirtualMachine in the exact way you want. Infrastructure as Code from start to finish. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/vagrant/issues
Discuss: https://discuss.hashicorp.com/c/vagrant/24
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/506a795d-30ce-4e4b-b384-22850e3aac91o%40googlegroups.com.


--
Dan Morgan

Alexander Solla

unread,
Jul 14, 2020, 6:08:32 PM7/14/20
to vagra...@googlegroups.com
I'd say that the best practice is to pick some configuration management system like Ansible, Salt, or Puppet that Vagrant supports, and use that to keep your configuration files in version control. 

The idea would be to have Vagrant provision whatever system (Salt, etc) you end up using, and then have that system (Salt, etc) provision the configuration on your machine.

--

Jason Williams

unread,
Jul 15, 2020, 12:43:00 AM7/15/20
to Vagrant
Thank you. I have been looking into that.
I also looked into using Packer to build my images. Basically, the flow would be, build images with Packer and then pass them off to Vagrant to be used as vagrant boxes.

Is there a "best" option for configuration the box/vm? Should I do it in Packer? Should I do it with Ansible and vagrant? 
Is there a cleaner approach that allows me to operate as Infrastructure as Code (make changes to a VM, to ensure I can use future created vms/boxes with the VM's I created?

I understand everything conceptually just trying to connect all the dots properly now.
Appreciate the help.!

On Tuesday, July 14, 2020 at 3:04:35 PM UTC-7, . wrote:
This is where Ansible  https://docs.ansible.com/  would come in to help you provision the VirtualMachine in the exact way you want. Infrastructure as Code from start to finish. 

On Tue, Jul 14, 2020 at 4:47 PM Jason Williams <jason.w...@gmail.com> wrote:
hello everyone.
I am starting to use Vagrant and Virtualbox more and more in my testing/development work. The more I work with the two, the more ideas and questions I have. I was hoping for some guidance/clarification and maybe best practices.
Let me start with what I am working on and what I have done.

I use NGINX quite a bit for web servers, proxying and load balancing.
I have successfully setup a multi-vagrant setup using 2 servers to serve content. Step in the right direction.

Where my question is really at is, once I spin up my Vagrant environment and start to do my testing, I see there are things that I need to change with the current boxes that I am using.
This could be things like additional software, specific configuration file settings, copying over content etc.

That all being said, is the best practices approach to then package up one of my current boxes which will contain all my changes? If that is true, what if I have I have different boxes in a multi-vagrant setup? Do i just package each one individually?
Lastly, how do I call/use these new boxes that I have created? Do i need to edit the Vagrantfile and change the speciic image being used?

This is where my rookiness to Vagrant is coming up short and was hoping the more experienced users could shed some light.

I appreciate the help!

Cheers!

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/vagrant/issues
Discuss: https://discuss.hashicorp.com/c/vagrant/24
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagra...@googlegroups.com.


--
Dan Morgan

Jason Williams

unread,
Jul 15, 2020, 12:43:59 AM7/15/20
to Vagrant
Thank you, yes. I would agree. I have am comfortable with Ansible and how it works. now I just need to put it all together.
Per the above, i mentioned Packe ras well, not sure where that fits into the flow of what I am trying.

TY

On Tuesday, July 14, 2020 at 3:08:32 PM UTC-7, Alexander Solla wrote:
I'd say that the best practice is to pick some configuration management system like Ansible, Salt, or Puppet that Vagrant supports, and use that to keep your configuration files in version control. 

The idea would be to have Vagrant provision whatever system (Salt, etc) you end up using, and then have that system (Salt, etc) provision the configuration on your machine.

On Tue, Jul 14, 2020 at 1:47 PM Jason Williams <jason.w...@gmail.com> wrote:
hello everyone.
I am starting to use Vagrant and Virtualbox more and more in my testing/development work. The more I work with the two, the more ideas and questions I have. I was hoping for some guidance/clarification and maybe best practices.
Let me start with what I am working on and what I have done.

I use NGINX quite a bit for web servers, proxying and load balancing.
I have successfully setup a multi-vagrant setup using 2 servers to serve content. Step in the right direction.

Where my question is really at is, once I spin up my Vagrant environment and start to do my testing, I see there are things that I need to change with the current boxes that I am using.
This could be things like additional software, specific configuration file settings, copying over content etc.

That all being said, is the best practices approach to then package up one of my current boxes which will contain all my changes? If that is true, what if I have I have different boxes in a multi-vagrant setup? Do i just package each one individually?
Lastly, how do I call/use these new boxes that I have created? Do i need to edit the Vagrantfile and change the speciic image being used?

This is where my rookiness to Vagrant is coming up short and was hoping the more experienced users could shed some light.

I appreciate the help!

Cheers!

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/vagrant/issues
Discuss: https://discuss.hashicorp.com/c/vagrant/24
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagra...@googlegroups.com.

.

unread,
Jul 15, 2020, 5:00:13 PM7/15/20
to vagra...@googlegroups.com
Think of it like this. 

To test/use your Image locally:

Vagrant => Creates a VM and Runs Ansible*  => Provisions the Virtualbox in the exact way you want it.

Virtualbox = VM Hypervisor (Could also be VMWare, Docker, etc)
Vagrant = Programatically set up a VM with the amount of RAM, CPU, Networking, etc. you want  
Ansible = Set up the VM with the packages, scripts, files, users, permissions, etc ... you need to make your application run

* I use Ansible, but as suggested by others, Salt, Chef, Puppet, CFEngine are all valid options as well

To test/use your Image in the cloud or even locally:

You could use Packer to create the Hypervisor Image (VMWare, Amazon EC2, Docker, SZure, GC, and even Vagrant)

The pattern, I believe, is called the roll-up pattern where you use Packer to generate Machine (Hypervisor) Images for the cloud (Operating System, RAM, CPU, etc) and manage the OS level stuff (files, users, permissions, etc) with Ansible (or something like it).

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/98bf52d1-ba71-4fc8-9007-98d0f06a65c7o%40googlegroups.com.


--
Dan Morgan

dragon788

unread,
Jul 18, 2020, 12:11:43 PM7/18/20
to Vagrant
Github.com/boxcutter/ has some great examples with various different configuration management told actually for automatic installation.

jason.wi...@gmail.com

unread,
Jul 20, 2020, 1:31:27 PM7/20/20
to Vagrant
Heya. Thank you for your input. I spent a good amount of time testing this over over the weekend and came up with the following. Be curious to hear others thoughts:
1. Use Packer to build a 'clean' image for whichever provider (Vmware, virtualbox, GCE, AWS, Azure etc.)
2. I pass that to Vagrant.
3. Import the packer box with Vagrant.
4. Using Vagrant now, I see two options.
   a. One, I can use ansible within vagrant as my provisioner, to call Ansible, do some stuff to the OS, install packages, setup etc.
   or.
   b. On the host box, I could call ansible directly, specify a inventorry file with the virtualbox VM's, and call whichever playbooks I want.

Does that seem about on par?
I can so pros and cons to both.
Much appreciated!

D Morgan

unread,
Jul 20, 2020, 2:40:23 PM7/20/20
to Vagrant
This is ultimately about what is best for your workflow as both options are completely valid.

A major pro for option A is that it's what Vagrant recommends and as such it's super popular and (I would imagine) the most common use case in the wild largely due to how teams/developers develop on their individual machines.

I use something closer to option B for running tests in Travis-CI but not development. 

jason.wi...@gmail.com

unread,
Jul 21, 2020, 12:51:30 PM7/21/20
to Vagrant
Thanks again for your input. I can see pros and cons to both. I am leaning towards Option B. The way I see it, I can have more control with option B when i setup my inventory file and playbooks. It *appears* to be more flexible in that you can have certain playbooks run against specific hosts.
I think A works out of the box (no pun intended) a bit better, but might lack robustness.

This has made me explore how to use standard `ssh` instead of `vagrant ssh` in how I can use ansible to connect to the box.
Overall, my understanding of IaC has taken a tremendous leap forward and gives me lots of ideas moving forward.

Thank you again!

dragon788

unread,
Jul 21, 2020, 5:19:57 PM7/21/20
to Vagrant
`vagrant ssh-config` should show what you need.

jason.wi...@gmail.com

unread,
Jul 21, 2020, 7:45:42 PM7/21/20
to Vagrant
Yep. Was just looking at that. Looks like I could just add this to my .ssh/config file, using native SSH.
Exploring using the ansible inventory file in a multi-vm setup, how to populate it with the correct names.
Much obliged.
Reply all
Reply to author
Forward
0 new messages