Instant LAMP Stack with Vagrant and Puppet

Post on 05-Dec-2014

5.086 views 3 download

description

Do you enjoy installing and configuring Apache, PHP, and MySQL every time you reinstall your OS or switch to a new machine? Neither do I. And we never have to do it again. Vagrant can use the VirtualBox API and configuration defined in Puppet to spin up a development VM in a couple of minutes. And it's really easy to do. I'll start with the simplest possible example and work up to a cluster of VM's. Feel free to bring your laptop and follow along.

Transcript of Instant LAMP Stack with Vagrant and Puppet

Instant LAMP Stack with Vagrant and Puppet

Patrick LeeBoise Code Camp

March 16, 2013

Resources

Code: https://github.com/patrickdlee/vagrant-examples *Slides: http://www.slideshare.net/patrickdleeMe:● @patrickdlee on Twitter● Patrick.Lee@bodybuilding.com

* Use the vagrant1.1 branch.

Who am I?

● Former high school teacher (5 years)● Recovering software developer (10 years)● Brand new release engineer (one week)● Organizer of Boise Web Tech Meetup (4 years)● Incurable techie (38 years and counting)

I have worked at Bodybuilding.com for 4-1/2 years. Yes, we are hiring. Talk to me if you're interested.

Assumptions

I am assuming that you are familiar with the following or at least know of them...

● VirtualBox● Linux● Apache / PHP / MySQL● Software configuration● Cloud computing

But if not, I'll explain them briefly so don't worry.

A brief analogy

Remember the days before source control?What did you do? Zip files named by date?Do you miss doing that?

Here's the analogy...

Vagrant : manual env setup :: Zip files : SCM

Agenda

● What is the problem anyway?● What is Vagrant?● Examples!● What is Puppet?● More examples!● Simulating production architecture?● Even more examples!● Integration with Amazon AWS● One more example!● Related topics● Questions?● Links

What is the problem anyway?

Setting up a development environment is not a fun way to spend an afternoon.

Options:● Using a remote server● Installing everything locally● Creating a virtual machine

Let's take a look at each of these...

Using a remote server

Pros:● It's separate from your machine● No divergence of environments on team● You can rebuild your own machine at will

Cons:● You have to push code to it● You probably have to share it with others● It's just inefficient at best● What if you're out of the office?

Installing everything locally

Pros:● You have complete control over it● Nobody else is breaking using it

Cons:● It's time-consuming and error-prone● It's not easily repeatable● Barrier to rebuilding your machine● No standards among teammates

Creating a virtual machine

Pros:● It keeps your own machine cleaner● VM's can be snapshotted● VM's are (mostly) portable

Cons:● Initial installation is time-consuming● Virtual machine images are big● There's still configuration when copying them

Enter Vagrant!

Pros:● Can be run entirely on your machine● Defines all configuration externally● Consistent, repeatable, and reliable● Can standardize environments for your team● Keeps your own machine cleaner● You can rebuild your own machine at will

Cons:● Expectation of increased productivity?

What is Vagrant?

Vagrant is a tool that allows developers to..."Create and configure lightweight, reproducible, and portable development environments."

● Created by Mitchell Hashimoto● Open source and on GitHub● Available for Linux, Mac, and Windows● Uses Oracle's VirtualBox● Uses Puppet or Chef for provisioning

Examples!

What is Puppet?

"Puppet is IT automation software that helps system administrators manage infrastructure throughout its lifecycle, from provisioning and configuration to patch management and compliance."

● Define all your configuration in text files● Apply the configuration to your machines● Modify the configuration at any time● Ensure that all machines are up-to-date● Straightforward, yet powerful technology

More examples!

Simulating production architecture?

A single VM is all well and good, but we need to simulate production.

No problem!

● Create as many types of VM's as you like● Spin up one of each or entire clusters● The only limit is your hardware

Even more examples!

Integration with Amazon AWS

Vagrant 1.1 (released 3/14) supports multiple providers...

● VirtualBox (the default)● Amazon AWS● Rackspace Cloud● VMWare● ...and more to come.● You can even add your own.

One more example!

Related topics

PuppetForge is a repository of Puppet modules provided by the community.

rspec-puppet is a tool for testing Puppet modules.

Chef is another option for provisioning with Vagrant.

AWS OpsWorks is a new service for configuration management, provisioning, application deployments, auto-scaling, routing, load balancing, and more.

Questions?

Links

● http://www.vagrantup.com/● https://puppetlabs.com/● http://forge.puppetlabs.com/● http://rspec-puppet.com/● http://www.opscode.com/chef/● https://aws.amazon.com/opsworks/