Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Hands-On DevOps with Vagrant
Hands-On DevOps with Vagrant

Hands-On DevOps with Vagrant: Implement end-to-end DevOps and infrastructure management using Vagrant

eBook
€15.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Hands-On DevOps with Vagrant

Introduction

You are about to embark on an exciting journey focused on Vagrant and its role within DevOps. Throughout these chapters, you will learn interesting and useful facts, as well as tips and tricks, about Vagrant. Initially, we will focus on the basics of Vagrant and getting it installed and running on your machine. We will then venture through its ins and outs, by focusing on the important parts of Vagrant, such as its commands, networking, multi-machine, Vagrantfiles, and using configuration management tools, such as Chef, Docker, and Ansible. By the end of this book, you will have solid foundational knowledge about Vagrant and the necessary skill set to start using it on a day-to-day basis as part of your DevOps workflow. 

In this chapter, we will create a solid foundation that will help you understand what Vagrant is, what VirtualBox is, and how Vagrant ties into the DevOps landscape. We will learn about the current state of development tools in DevOps and focus on how Vagrant can be used by many different teams in an organisation—not just developers! By the end of this chapter, you will have a good understanding of the basics of Vagrant, VirtualBox, and DevOps.

Getting started with Vagrant and DevOps

In this section, you will be introduced to Vagrant and learn about its features, benefits, and its role in the development tools used in the DevOps world. 

Understanding Vagrant

Vagrant is very simple on the surface, but is actually incredibly complex under the hood. It allows you to quickly and effortlessly create virtual environments (known as Vagrant boxes) and customize them. Vagrant easily integrates with multiple providers, such as VirtualBox, VMware, and Docker. These providers actually power the virtual environments, but Vagrant provides a customizable API to that virtual machine.

Vagrant has a large selection of commands, which can be used from the command line/Terminal to manage virtual environments. These commands can quickly download and set up an environment from the Vagrant cloud, which hosts many popular environments, such as Ubuntu or PHP's Laravel.

Vagrant is an important piece of software that can be found in many programmers' toolboxes. It is commonly used to tackle the well-known phrase, It works on my machine, by allowing everyone to have a copy of the same environment.

Vagrant was created by Mitchell Hashimoto and released in March 2010. Vagrant is now part of the HashiCorp company, which Mitchell Hashimoto cofounded in 2012 with Armon Dadgar. Vagrant is an open source piece of software that has been built in the Ruby language. It is currently being licensed under the MIT license. Vagrant can be run on macOS, Windows, FreeBSD, and Linux.

Vagrant is essentially another layer in the virtualization stack. It acts as an easily programmable interface to control virtual environments. Vagrant relies on a provider, such as VirtualBox, to power these environments, but it can also configure providers so they work in harmony  an example would be Vagrant controlling how much memory (RAM) an environment has.

Vagrant features

Vagrant offers many features to help you build and configure virtual environments. Vagrant features can be split into a few key areas—Vagrantfile, boxes, networking, provisioning, and plugins. Vagrant can be managed in two key ways  the command line and a Vagrantfile. The command-line approach is often used for admin tasks, such as downloading/importing a new Vagrant box or deleting an old one.

Vagrantfile

A Vagrantfile is a configuration file that uses the Ruby programming language syntax. It is easy to understand and can be quickly tested by making a change and then running the vagrant up command to see whether the expected results happen. A Vagrantfile can easily be shared and added into version control. It's lightweight and contains everything needed for another user to replicate your virtual environment/application.

Boxes

Vagrant boxes are packages that, similar to Vagrantfiles, can be shared and used to replicate virtual environments. Vagrant boxes can be easily downloaded by running the vagrant box add command. The Vagrant cloud offers an easily searchable catalogue of boxes. The Vagrant cloud provides lots of information about a box, such as the creator, the version, how many times its been downloaded, and a brief description.

Networking

Vagrant supports three main types of networking when creating virtual environments: public networks, private networks, and port-forwarding. The simplest networking option is port-forwarding, which allows you to access a specific port through the guest operating system into the Vagrant machine. Public and private networking are more complex and offer more configuration, but we will cover that in future chapters.

Provisioning

Provisioning in Vagrant offers you a way to configure the Vagrant machine even more. You can install software and dependencies as the machine is being created. To provision a Vagrant machine, you can use shell scripting, Docker, Chef, Ansible, and other configuration-management software, such as Puppet.

Plugins

Vagrant plugins offer another way to customize and extend the functionality of Vagrant. They allow you to interact with the low-level aspects of Vagrant and often provide new commands to be used as part of the Vagrant command line.

Advantages of Vagrant

Vagrant allows you to easily package up a virtual environment that can be shared among fellow developers. This packaged virtual environment is often referred to as a Vagrant box. A box can be configured to mirror the production environment where your web application or code will be running. This can help minimize any bugs or issues when your application/code is deployed to the production environment.

The beauty of Vagrant's configuration (known as a Vagrantfile) is often small and can be easily edited and tested. The syntax of a Vagrantfile is easy to understand and offers a simple way to build a complex environment.

Vagrant can be used by many different members of a team, including those on the development team, the operations team, and the design team. 

Development team

For a developer, Vagrant can allow them to package up their code/application into an easily-sharable fully-fledged development environment. This can then be used by developers using different operating systems, such as macOS, Linux, or Windows. 

Operations team

The operations team can easily and quickly test deployment tools and scripts using Vagrant. Vagrant supports many popular deployment tools in the operations/DevOps world, such as Puppet, Docker, and Chef. Vagrant can be a cheaper and faster way to test deployment scripts and infrastructure topologies. Everything can be done locally with Vagrant or it can be used with a service such as Amazon Web Services.

Design team

Vagrant allows the development team and operations team to create virtual environments running code, and applications ready for a designer to easily run this environment on their machine and start making edits to the application. There is no configuration required and feedback can be instant, from when a developer makes a change or a developer has to update the Vagrantfile.

What is VirtualBox?

VirtualBox is one of the many providers that Vagrant supports. VirtualBox is a powerful virtualization tool that allows you to create virtual environments on your existing operating system. It allows you to fully customize a virtual machine's hardware, such as the RAM, CPU, hard drive, audio, and graphics.

VirtualBox was initially released in January 2007 by the company Innotek GmbH, which was later acquired by Sun Microsystems, which, in turn, was acquired by the Oracle Corporation. Oracle is actively maintaining and releasing new versions of VirtualBox.

VirtualBox is built in x86 Assembly, C++, and C. It can run and supports many different operating systems, such as Windows, Linux, Solaris, and OS X.

What is DevOps?

DevOps is a popular term in the IT world at the moment. There are many different opinions as to what DevOps actually is. In simple terms, DevOps is the mix of development and operations. It is essentially creating a sort of "hybrid programmer" who knows about operations and infrastructure, or a system admin who understands programming and can develop applications.

DevOps is a mixture of methodologies, practices, philosophies, and software. DevOps streamlines the whole project life cycle by creating a workflow that works for all departments. There are no rules or laws in DevOps, but generally it's the process of connecting the developers and the infrastructure team by enabling an easy way to develop and ship code.

The beauty of DevOps is that any company can start following its ideas, methodologies, and best practices. Large companies may have a whole DevOps department/team, whereas smaller companies may just need one or two dedicated DevOps employees. In a start-up scenario, where money must be carefully budgeted, one employee may take on the role of developer and also DevOps.

Vagrant for DevOps

In this chapter, you will learn about the current state of development in DevOps, how Vagrant fits into DevOps, and how to use Vagrant as a day-to-day DevOps tool. By the end of this chapter, you will have a much better understanding of how Vagrant can be used for development as part of the DevOps process.

Current state of development within DevOps

As mentioned previously, DevOps is a mixture of software development, operations/system administration, and testing/quality assurance. DevOps is not a new movement, but one that doesn't necessarily have a leader or a set of rules and standards to follow. Every company has their own idea of what DevOps is and how it should be implemented. Many follow similar paths or rough guidelines. Due to the lack of governance with DevOps, the current state of development is varied.

Traditionally, development has always been separate to the operations and server team, but in the last few years, we have seen many DevOps tools bridge that gap and make life easier for both sides.

In the past, when a web developer would build a web application, they would code it, built it locally on their machine, and then FTP (file transfer) the files onto a live (production) server to then run the code—if there were any issues or bugs, the developer would have to make changes to the server environment and debug the code. There are many developers who still use this workflow and it may be because of their environment or because they have no choice in the matter.

Today, a modern web developer's workflow may look like this:

  1. The developer writes their code locally but through a virtual environment/machine with a tool such as Vagrant. This allows the developer to set up an environment such as the production one.
  2. The developer edits to their code and uses version-control (such as Git or Subversion) to manage changes. The version-control is set up in a way that allows the developer to keep test/new code separate from the production code.
  3. A continuous integration (CI) tool (such as Jenkins or Travis CI) is used to create a pipeline that often has three separate stages—development, staging, and production. The CI tool can be used to run tests against the software, and run scripts such as performing assets by combining and minifying them. The version-control software can be linked into the CI tool, which often triggers these builds and tests. When the developer pushes some new code to the staging environment, tests can be run before it reaches the production environment.
  4. Often, if the tests run and there are no issues, the code may be pushed directly into the production branch in the version control. At this point, the CI tool may trigger a new build, which would essentially restart the service that the code applies to. This could be simple or complex, depending on the production environment and software architecture.
  5. At some stages during this process, there may be manual intervention by the QA (quality assurance/testing) team or more senior developers who wish to check the code before it goes to production.

Of course, this is just an example workflow and will differ between companies and development teams. The modern workflow may seem much more complicated and tedious, but this is for good measure. At each stage, you'll notice there are checks and tests run before the code can reach a live production environment where real users may be interacting with that code. This can be incredibly important when working with financial software and other business-critical software. This modern workflow greatly reduces the margin of error.

Modern development in the DevOps world is focused on speed and automation. The focus on speed is the ability to quickly build a feature or fix a bug and "push the code to production" (a phrase you might have heard!). This means that single developers or a team of developers have less of a barrier when working on the code. A developer shouldn't worry about configuring servers or environments.

Automation is a big part of DevOps, and that effects the development part too. You can imagine how slow a process it would be if a developer made changes to their code and then had to wait for a member of the operations team to manually run tests and scripts against their changes before letting them know the result. 

Vagrant and DevOps

I believe that Vagrant is a key tool in a developer's toolbox in today's DevOps-focused world. Vagrant is essentially a suite of tools that allows the developer to create code but also connect with configuration management tools, such as Puppet, Chef, and Ansible, that are used to automate workflows and environments on servers.

Vagrant's primary focus is on development and enables an easy way for every developer on the team to use the same environment. Within a Vagrant environment, you can run version-control that could link into the CI workflow, which allows you to run tests and move code into different stages.

Using Vagrant as a day-to-day DevOps tool

Vagrant is a flexible tool that enhances day-to-day development by allowing you to easily test out DevOps workflow ideas. It allows you to separate your software code and infrastructure without having to know much about DevOps, infrastructure, servers, and configuration-management tools. 

As a day-to-day DevOps tool, Vagrant can be used for many things, including the following:

  • Testing software code in different environments and operating systems
  • Testing different workflows using configuration-management tools, such as Chef and Puppet
  • Working in the same environment as other developers in your team/company
  • Easily make changes to Vagrant and see the results instantly
  • Running multiple environments/virtual environments to test out networking, file-sharing, and other multi-server use cases

Summary

In this chapter, we learned that Vagrant is a very powerful and flexible tool for helping create virtual environments that can mimic staging and development environments used by your business or application. We looked at the current development state of DevOps, how Vagrant fits into that, and how to use Vagrant as a day-to-day development tool.

In Chapter 2, Installing VirtualBox and Vagrant, we will install Vagrant and its provider, VirtualBox. We will look at how to install these pieces of software on a Windows, Mac, and Linux machine. You will also learn how to find out your system's version and its CPU architecture.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Implement DevOps with Vagrant effectively
  • Integrate Vagrant with different tools such as Puppet, Chef, and Docker
  • Manage infrastructure with a practical approach

Description

Hands-On DevOps with Vagrant teaches you how to use Vagrant as a powerful DevOps tool and gives an overview of how it fits into the DevOps landscape. You will learn how to install VirtualBox and Vagrant in Windows, macOS, and Linux. You will then move on to understanding Vagrant commands, discovering its boxes and Vagrant Cloud. After getting to grips with the basics, the next set of chapters helps you to understand how to configure Vagrant, along with networking. You will explore multimachine, followed by studying how to create multiple environments and the communication between them. In addition to this, you will cover concepts such as Vagrant plugins and file syncing. The last set of chapters provides insights into provisioning shell scripts, also guiding you in how to use Vagrant with configuration management tools such as Chef, Ansible, Docker, Puppet, and Salt. By the end of this book, you will have grasped Vagrant’s features and how to use them for your benefit with the help of tips and tricks.

Who is this book for?

Hands-On DevOps with Vagrant is for you if you are a system administrator, DevOps engineer, DevOps architect, or any stakeholder working with DevOps and wanting to explore Vagrant. Experience in system administration is needed to enjoy this book.

What you will learn

  • Explore what development features Vagrant offers
  • Install Vagrant and VirtualBox on Windows, macOS and Linux
  • Harness the power of Vagrant to create powerful development environments
  • Utilize DevOps tools such as Docker, Chef, and Puppet
  • Understand everything about Vagrant, including networking, plugins, and provisioning
  • Use the Vagrant Cloud to install and manage Vagrant boxes

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 17, 2018
Length: 232 pages
Edition : 1st
Language : English
ISBN-13 : 9781789138054
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Oct 17, 2018
Length: 232 pages
Edition : 1st
Language : English
ISBN-13 : 9781789138054
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 113.97
Mastering Docker
€41.99
Learn Ansible
€41.99
Hands-On DevOps with Vagrant
€29.99
Total 113.97 Stars icon

Table of Contents

15 Chapters
Introduction Chevron down icon Chevron up icon
Installing VirtualBox and Vagrant Chevron down icon Chevron up icon
Command Line-Interface - Vagrant Commands Chevron down icon Chevron up icon
Discovering Vagrant Boxes - Vagrant Cloud Chevron down icon Chevron up icon
Configuring Vagrant Using a Vagrantfile Chevron down icon Chevron up icon
Networking in Vagrant Chevron down icon Chevron up icon
Multi-Machine Chevron down icon Chevron up icon
Exploring Vagrant Plugins and Syncing Files Chevron down icon Chevron up icon
Shell Scripts - Provisioning Chevron down icon Chevron up icon
Ansible - Using Ansible to Provision a Vagrant Box Chevron down icon Chevron up icon
Chef - Using Chef to Provision a Vagrant Box Chevron down icon Chevron up icon
Docker - Using Docker with Vagrant Chevron down icon Chevron up icon
Puppet - Using Puppet to Provision a Vagrant Box Chevron down icon Chevron up icon
Salt - Using Salt to Provision a Vagrant Box Chevron down icon Chevron up icon
Other Book You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(3 Ratings)
5 star 66.7%
4 star 33.3%
3 star 0%
2 star 0%
1 star 0%
C. C Chin Dec 09, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Ansible at office
Amazon Verified review Amazon
Randy Harris May 01, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I found the book very easy to read. I usually read a chapter or two when reading a technical book. Just enough to get the information I need before putting the book down. This book was so easy to read that the author kept my interest from page one to the end. I found the chapter on chef a little dry, but the chapters on puppet and salt were very easy reads that held my interest. I read Mitchell Hashimoto's book on Vagrant some years ago and the documentation on the Hashicorps website. Still, I found Alex Braunton's book to be well thought out, clear, and concise. Alex Braunton should write another DevOps book soon because he has the talent for it.
Amazon Verified review Amazon
Kindle Customer Feb 07, 2019
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Having dabbled with KVM, Xen, Virtualbox and VMWare just to test and play around with linux recipes became tiring when repeating exercises & server config tests. Therefore in this book when playing with recipes whilst learning vagrant you get the advantage of doing more in a short time including testing configs more easily as you don't have to mess around a lot configuring your VMs. In short get this book as part of your devops foundational knowledge as it will boost your tech skills to warp speed.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.