Fork me on GitHub

Phansible provides an easy-to-use interface that helps you generate Ansible provisionings for PHP-based projects.

Vagrant Crash-course

Vagrant is a tool that enables creation of development environments that are portable, reproducible and disposable. With a simple vagrant up, a virtual machine is booted and configured to run your application.

Phansible helps you bootstrap a Vagrant project using Ansible as provisioner. This page gives you a hand if you are new to Vagrant.

Installation

Head to the Vagrant downloads page and get the appropriate package for your OS. You'll need to have VirtualBox installed as well - download the newest version from here.

Vagrant Commands

This is a quick reference on the basic Vagrant commands:

Command Description Common Usage
up Boots up the machine and fires provision When the VM is not running yet
reload Reboots the machine When you make changes to the Vagrantfile
provision Runs only the provisioner(s) When you make changes in the Provisioner scripts
init Initializes a new Vagrantfile based on specified box url When you want to generate a Vagrantfile
halt Turns off the machine When you want to turn off the VM
destroy Destroys the virtual machine When you want to start from scratch
suspend Suspends execution When you want to save the machine state
resume Resumes Execution When you want to recover a previously suspended vm
ssh Logs in via ssh (no password is required) When you want to make manual changes or debug
global-status Shows global information about VMs When you want to check which VMs are running and control them individually

Vagrant Terminology

Boxes

A box is basically a bundle containing an installed operating system (and some basic stuff), for a specific provider (e.g. VirtualBox). Vagrant will replicate this basic image for your virtual machine. When you setup your project, you define which base box you want to use. The box will be downloaded and imported to the system when you use it for the first time.

Host and Guest

The Host machine / OS is the one who starts Vagrant. The Guest machine, as you can guess, is the virtual machine started by the Host.

Providers

A provider will handle the virtualization process. VirtualBox is the default Vagrant provider, but you could also use VMWare, KVM and others. Installation of extra plugins might be required for other providers to work. VMWare, for instance, also requires registering a license key.

Plugins

A plugin can add extra functionality to Vagrant, like supporting a new Provider.

Provisioners

A provisioner will automate the setup of your server, installing packages and performing tasks in general. Using a provisioner is not mandatory, but not using it would make Vagrant worthless, since you would have to login and setup your environment manually, just as you were used to do before (and you could just use VirtualBox alone). Phansible uses Ansible as provisioner.

Vagrantfile

The Vagrantfile will hold your machine definitions, and it's usually placed on your application root folder. This file is written in Ruby, but it's basically a set of variable definitions, very straightforward. We'll have a chapter dedicated to the Vagrantfile and its common configuration options.

Shared / Synced Folder

It's useful to have a common space shared between the Host and the Guest machines. With a shared folder, you can still edit your files with your favorite IDE installed on the Host machine, using the Guest machine only as a test server.

This quick Vagrant manual is kindly brought to you by Vagrant Cookbook