Description
If you have written software on a desktop computer and attempted to deploy your code to another computer (a server), you have already encountered the challenges presented when deploying software. Developers and administrators frequently struggle with errors and defects, when development environments are different from the eventual production machines. There can be a number of differences introduced when the environments are different at the operating system level. Development with desktop operating systems (such as Windows or OS X) can introduce many issues when deploying to production environments that run a Unix (or Linux) environment.
The introduction of desktop hypervisor software allowed developers to develop and test software using virtual machines. A virtual machine is essentially a system within a system, wherein developers working on a desktop operating system can develop and deploy with a copy of the operating system and environment that closely mimics the eventual production environment. When desktop hypervisors became available, development teams found that they could share development environments by sharing the files used by the hypervisors to store the state of virtual machines. In many cases, sharing a virtual machine involved passing around copies of files on a portable hard drive or a shared network folder.
A few years ago, I encountered this specific example when working on a project that involved adding new features to software that ran on an environment, which we could not support with our modern desktop hardware. As many projects reveal, technical debt was introduced to the application by using some very specific features of the Java Development Kit (version 1.5), an environment that was impossible to work on with a 64-bit OS X machine. This machine had dual problems of being a 64-bit machine and it also lacked native support for Java 1.5 XML libraries. The solution to this problem was the creation of a single virtual machine that was shared between developers, passing around a copy of the machine created by a team lead and using it locally to compile and test our modifications.
As time passed by, changes to the environment became an issue, as we began struggling with the differences between not only the development and production environments, but also between our individual development environments as changes were made, making sure that each developer was working on the latest version of the virtual machine on that portable hard drive, which soon had a few different versions itself.
Table of Contents
Preface
Chapter 1: Setting Up Your Environment
Introduction
Installing Vagrant and VirtualBox
Initializing your first environment
Installing Vagrant providers
Finding additional Vagrant boxes
Using existing virtual machines with Vagrant
Chapter 2: Single Machine Environments
Introduction
Defining a single machine Vagrant environment
Forwarding ports from a Vagrant machine
Starting a GUI with Vagrant
Sharing Vagrant guest folders with the host
Sharing folders using Network File Systems
Sharing folders with rsync
Customizing virtual machine settings (VirtualBox)
Customizing virtual machine settings (VMware Desktop)
Sharing environments with source control
Chapter 3: Provisioning a Vagrant Environment
Introduction
Running basic shell commands
Executing shell scripts in a Vagrantfile
Provisioning with external shell scripts
Chapter 4: Provisioning with Configuration Management Tools
Introduction
Configuring Vagrant environments with Puppet
Configuring Vagrant environments with Chef
Provisioning Vagrant environments with Salt
Provisioning Vagrant environments with Ansible
Chapter 5: Networked Vagrant Environments
Introduction
Creating a local network
Defining a multimachine environment
Specifying the order of machine provisioners
Creating clusters of Vagrant machines
Chapter 6: Vagrant in the Cloud
Introduction
Using Vagrant with Amazon Web Services
Using Vagrant with DigitalOcean
Sharing local machines with HashiCorp Atlas
Sharing web applications with HashiCorp Atlas
Chapter 7: Packaging Vagrant Boxes
Introduction
Packaging Vagrant boxes from ISO files
Building Vagrant boxes with Packer
Sharing Vagrant boxes
Sharing Vagrant boxes with Atlas
Appendix A: Vagrant Plugins
Setting up a Ruby runtime environment
Appendix B: A Puppet Development Environment
Setting up a Puppetmaster with the puppet apply provisioner
Provisioning nodes with a Puppetmaster
Appendix C: Using Docker with Vagrant
Introduction
Running Docker containers with Vagrant
Mixed environments – the Docker provisioner
Index