Git Product home page Git Product logo

packer-vagrant-example's Introduction

Vagrant Packer Example

This repository contains an example packer configuration for building a custom vagrant base box for virtualbox, and a vagrant configuration for using that base box.

To use the contents of this repo you will need the following installed

  1. VirtualBox - http://www.virtualbox.org/
  2. Vagrant - http://www.vagrantup.com/
  3. Packer - http://www.packer.io

Packer installation involves downloading the package for your OS (most Mac users will want the amd64 package) and moving the contents of the zip file to an executable path such as /usr/bin

This repo is setup to create an Ubuntu 13.10 Server image pre-loaded with:

  • Apache 2.4
  • PHP 5.5 w/ Extensions
    • GD
    • MySQL
    • Memcached
    • XDebug
    • PHPUnit
    • Composer
  • MySQL 5.5
  • Node.js w/
    • Grunt
    • Bower
    • NodeUnit
  • Memcached
  • Imagemagick
  • git
  • vim
  • wget
  • zip/unzip

MySQL is setup with a root password of vagrant.

Note that this config does NOT install Puppet or Chef, as they are not needed when all packages are pre-installed.

##Packer Config

The packer configuration consists of three parts:

  1. The packer json file ubuntu.json
  2. The preseed.cfg file used instruct the linux installer
  3. Post-install scripts in scripts/ which are executed in the order defined in the json file.
    • vagrant.sh which sets up the ssh key and password-less sudo needed by vagrant to admin the VM
    • vboxguest.sh which installs the VirtualBox Guess Additions
    • packages.sh which installs our pre-provisioned software packages
    • compact.sh which cleans up the machine and prepares it for boxing

Start the build process by invoking this command from inside the packer folder of this repo.

packer build ubuntu.json

Packer will download the Ubuntu install iso as well as the VirtualBox Guest Additions and then launch a virtualbox vm to perform the installation in. This entire process requires no user input, so just let it run. The terminal will tell you what Packer is currently doing while the VM is running. After ubuntu installation completes the VM will restart and packer will run the post-install scripts. This entire process will take 10-15 minutes.

Once packer reports "Build 'virtualbox-iso' finished." and exits, you will find a ready to use .box file in the build/ folder. This file will be somewhere around 560MB in size.

##Vagrant Config

Launch the vagrant configuration by invoking this command from inside the vagrant folder of this repo.

vagrant up

Vagrant will automatically import the box generated by Packer under the name packer-built. (Note that if you rebuild the image after launching this vagrant config, you will need to remove the "packer-built" box from vagrant before you'll get the new build.)

After the VM is booted it will provision the configuration files using the provisioning/initial-setup.sh file. This is a plain bash script that simply copies various config files from the provisioning/files folder.

Once the VM boots, you can visit http://192.168.56.151/ to confirm that Apache is running (it should display the phpinfo() output).

Apache is configured with a virtualhost of mypacker.dev to load from /srv/www.

PHP is configured with error reporting set to display all errors and to log errors to vagrant/srv/logs. A mail catcher script is also setup which causes all calls to mail() to output to vagrant/srv/logs/fakemail instead of attempting to send the email.

A .bashrc file is setup to add the vagrant/bin/ folder to the execute path, allowing any scripts added to it to be called directly.

##More Information

packer-vagrant-example's People

Contributors

twipped avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.