DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

SBOMs are essential to circumventing software supply chain attacks, and they provide visibility into various software components.

Related

  • Developing and Scaling a Microservice
  • Methods of Source Code Management and Data Protection
  • Power of Azure B Series Virtual Machines
  • CPU Optimization in Virtual Environment

Trending

  • Contract-Driven ML: The Missing Link to Trustworthy Machine Learning
  • Automating E2E Tests With MFA: Streamline Your Testing Workflow
  • Tableau Dashboard Development Best Practices
  • The Scrum Guide Expansion Pack
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. The Great Feature of Vagrant: Multi-Machine Management

The Great Feature of Vagrant: Multi-Machine Management

How to utilize Vagrant's ability to improve VirtualBox by managing and repairing your virtual machines.

By 
Rafael Salerno user avatar
Rafael Salerno
·
Sep. 08, 16 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
6.9K Views

Join the DZone community and get the full member experience.

Join For Free

Vagrant allows to be created a development environment that can be distributed. If you have a team that uses different operating systems, it is possible to assemble a virtual environment standard for all.

Vagrant can run with VirtualBox, by VmWare.Image title It can virtually automate the creation of a virtual machine to the virtual box. It can be considered a management tool for virtual machines, and is focused on creating environments that are similar or identical as possible to production servers.

Operating Systems that can be used: Windows, Ubuntu, Debian, and CentOS

Providers: VirtualBox, VmWare, Amazon Web Services.

Image titleProvisioners: Industry standard provisioning tools, such as shell scripts, Chef, Puppet, and Ansible, can be used to install and configure software on the machine automatically.

Reasons for Using Vagrant Over Just VirtualBox

1. Set Up Multi-VM Networks With Ease

Most of the Vagrant power-user content I've read has been about setting up multiple VMs at the same time. Vagrant gives you a single config file to set these up, enabling you to launch all of them with one command.

Say you've configured three VMs to network with each other using static IPs on the 192.168.1.* subnet. You find yourself in a location that is already using that subnet to hand out IP addresses, and your VMs now conflict. With Vagrant, you can simply edit the Vagrantfile and reload the VMs, whereas with VirtualBox you'd have to open the settings for each VM, if not boot each VM and change them inside.

2. Source Control

By putting the settings in a text file, it enables the configuration to be put under source control. Made some changes last week and accidentally broke the image? Just revert the changes and reload the VM. You can accomplish this with VirtualBox snapshots, but it will take up much more space than just a Vagrantfile.

3. Various Platforms

There are a large number of boxes available at sites such as http://vagrantbox.es. This enables you to try various OS's or distributions, applying the same provisioning to set up similar environments. This can help with testing or adding support to new platforms, and would be time-consuming using just VirtualBox.

Why

Vagrant allows you to create portable work environments, which can be easily reproduced on any system. It's useful for developers and system administrators who want to mimic a server's configuration on their local machine. It's useful for teams who want to quickly get designers and project managers up and running with a local installation.

Vagrant is a wrapper, which ties together several components including: virtualization software, such as VirtualBox; and a server base box, such as Ubuntu provisioning tools for configuration management, such as Chef.

Setup

The first step in configuring any Vagrant project is to create a Vagrantfile. The purpose of the Vagrantfile is twofold: 

  •  Mark the root directory of your project. A lot of the configuration of Vagrant is relative to this root directory.
  •  Describe the kind of machine and resources you need to run your project, as well as what software to install and how you want to access it.

The Vagrantfile is meant to be committed to version control with your project, if you use version control. This way, every person working with that project can benefit from Vagrant without any upfront work.

VagrantFile Sample

Image title

Puppet Sample

Image title

Multi-Machine

Vagrant is able define and control multiple guest machines per VagrantFile. These machines are generally able to work together or are somehow associate with each other. Accurately modeling a multi-server production topology, such as separating a web and database server. Modeling a distributed system and how they interact with each other. Testing an interface, such as an API to service component.

VagrantFile to Multi-Machine Sample

Image title

To Access Machines

  1. vagrant up

  2. vagrant ssh n1

  3. vagrant ssh n2

References

  • My slides

  • My SandBox

  • My Sample with Puppet

  • My sample with multi-machine using Serf

  • Automated Development Environments w/ Vagrant  -> good presentation

Virtual Machine Machine VirtualBox Power user The Industry Standard Virtual environment source control Version control Web Service

Opinions expressed by DZone contributors are their own.

Related

  • Developing and Scaling a Microservice
  • Methods of Source Code Management and Data Protection
  • Power of Azure B Series Virtual Machines
  • CPU Optimization in Virtual Environment

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: