Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf ·...
Transcript of Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf ·...
CustomInk
My Work
! Web Opera=ons at CustomInk ! Automate
! Support produc=on ! Develop Rails ! Monitor
! Deploy ! 20+ applica=ons in produc=on ! Etc.
Outside of work
! Coach Soccer for my kids ! Enjoy going to concerts
How are your produc=on servers built?
! git push heroku master ! server.txt ! Wiki page
! “Gold” VM image / AMI
! Infrastructure Automa=on framework ! Chef ! Puppet ! Cfengine
Problem
! Need to automate MongoDB server builds ! Mul=ple mongo instances running on one host
! Each mongo has unique configura=on seWngs
Developing a Solu=on
! Build out VM using ! Vagrant (for development purposes)
! Chef
Vagrant
! Tool for building and distribu=ng virtualized development environments
! Uses Oracle’s VirtualBox ! h^p://vagrantup.com
Get Started with Vagrant
! Install VirtualBox ! Install Vagrant
! gem install vagrant!! Create a VirtualBox image
! vagrant box add lucid64 http://files.vagrantup.com/lucid64.box!
! h^ps://github.com/mitchellh/vagrant/wiki/Available-‐Vagrant-‐Boxes
! h^p://www.vagrantbox.es/
Get Started with Vagrant
! Ini=alize the instance ! vagrant init!! Creates the Vagranaile – configures the VM
! Start-‐up the VM ! vagrant up!
! Login ! vagrant ssh!
Vagrant
! Six steps to get a VM running with Vagrant: ! Install VirtualBox ! gem install vagrant!! vagrant box add <box name> <box URL>!
! vagrant init <box name>!! vagrant up!! vagrant ssh!
! Next, configure the server with Chef
Chef
! Chef is an open source systems integra=on framework built to bring the benefits of configura=on management to your en=re infrastructure.
Chef Cookbooks
! Cookbooks -‐ encapsulate all the resources you need to automate your infrastructure and are easily sharable with other Chef users ! h^p://cookbooks.opscode.com/
! h^ps://github.com/opscode/cookbooks ! h^ps://github.com/37signals/37s_cookbooks ! h^ps://github.com/customink/cusotmink-‐cookbooks
Vagrant + Chef
! Vagrant supports provisioning a VMs with: ! Chef Solo ! Chef Server ! Puppet
PuWng it all together
! Use Vagrant to launch a VM ! Use Chef to provision MongoDB instances on the VM
! Connect to the MongoDB instances on the VM
Code walkthrough
! Next, we’ll walk through the installa=on and configura=on process
! 15 minutes to solu=on ! With VirutalBox already installed
Install Vagrant
Add and Ini=alize the Box
! We’re using lucid64 box ! Others are available ! Create your own
Vagranaile
On to Chef
! The base VM is ready to be launched ! Next we’ll move on to provisioning MongoDB with Chef
Set-‐up Chef Recipes
! Clone the CustomInk Chef repo ! Create some addi=onal directories
! mkdir –p cookbooks roles site-‐cookbooks/mongodb/recipes
! Create a role file ! Create a recipe for each MongoDB instance
Wait….what?
! Let’s define some of those chef terms ! Recipe
! fundamental configura=on unit in Chef ! Install MongoDB, Install Apache, etc.
! Cookbook ! Fundamental distribu=on unit and include:
! A^ributes, Recipes, Files, Templates, and more
! Role ! Group recipes and a^ributes ! Applied to a node
Logger MongoDB ! Recipe – fundamental configura=on unit in Chef
Catalog MongoDB
Chef Role ! Roles allow you to group recipes and a^ributes
Ready to launch
! Chef configura=on is complete ! We’re now ready to launch the VM
! First, we’ll need to revisit the Vagranaile
Updated Vagranaile
Build and Provision the VM
Verify MongoDB
Connect to MongoDB
Solu=on
! Use Vagrant + Chef to build and provision a local VM.
Quick Review
! Install VirtualBox ! gem install vagrant!! vagrant box add <box name> <box URL>!
! vagrant init <box name>!! Clone chef repo ! Add your own roles & recipes ! Update Vagranaile ! vagrant up!! vagrant ssh!
Developing Chef with Vagrant
! Vagrant is a great way to test your Chef recipes ! vagrant provision!
! re-‐run recipes ! Point your Vagranaile at a Chef server:
Chef is ready to cook MongoDB
! Provision test and produc=on servers ! Bootstrap using knife
! Knife – command line interface to chef
! Assign the Run List ! Assign using knife or the web UI
! Ini=alize the replica set ! Manual step at the moment
! Should be built into the chef recipes
Cool, I’m not using MongoDB
! No worries…I really want you to consider Vagrant and Chef
! How to you get a new developer working with your app? ! Include a Vagranaile in your repo ! Provide access to your chef repo ! Checkout and vagrant up
! Other cool vagrant features…
DC MongoDB Meet Ups
! Meet third Wednesday of every month ! Either in DC or at CustomInk in Tysons
! Next Meet Up is next Wednesday ! April 20 – 6:30 PM ! Library of Congress
Upcoming Shows
! Two great shows during Rails Conf ! Sunday Funday at Pier 6 ! Bonnaroo Buzz at Rams Head Live
Thank You!
! What ques=ons do you have?
Nathen Harvey
Web Opera=ons, CustomInk
Twi^er: @nathenharvey