provisioning mongodb)with) vagrantand)chef)files.meetup.com/347566/bmore_on_rails_chef.pdf ·...
TRANSCRIPT
![Page 2: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/2.jpg)
CustomInk
![Page 3: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/3.jpg)
My Work
! Web Opera=ons at CustomInk ! Automate
! Support produc=on ! Develop Rails ! Monitor
! Deploy ! 20+ applica=ons in produc=on ! Etc.
![Page 4: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/4.jpg)
Outside of work
! Coach Soccer for my kids ! Enjoy going to concerts
![Page 5: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/5.jpg)
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
![Page 6: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/6.jpg)
Problem
! Need to automate MongoDB server builds ! Mul=ple mongo instances running on one host
! Each mongo has unique configura=on seWngs
![Page 7: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/7.jpg)
Developing a Solu=on
! Build out VM using ! Vagrant (for development purposes)
! Chef
![Page 8: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/8.jpg)
Vagrant
! Tool for building and distribu=ng virtualized development environments
! Uses Oracle’s VirtualBox ! h^p://vagrantup.com
![Page 9: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/9.jpg)
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/
![Page 10: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/10.jpg)
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!
![Page 11: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/11.jpg)
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
![Page 12: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/12.jpg)
Chef
! Chef is an open source systems integra=on framework built to bring the benefits of configura=on management to your en=re infrastructure.
![Page 13: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/13.jpg)
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
![Page 14: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/14.jpg)
Vagrant + Chef
! Vagrant supports provisioning a VMs with: ! Chef Solo ! Chef Server ! Puppet
![Page 15: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/15.jpg)
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
![Page 16: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/16.jpg)
Code walkthrough
! Next, we’ll walk through the installa=on and configura=on process
! 15 minutes to solu=on ! With VirutalBox already installed
![Page 17: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/17.jpg)
Install Vagrant
![Page 18: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/18.jpg)
Add and Ini=alize the Box
! We’re using lucid64 box ! Others are available ! Create your own
![Page 19: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/19.jpg)
Vagranaile
![Page 20: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/20.jpg)
On to Chef
! The base VM is ready to be launched ! Next we’ll move on to provisioning MongoDB with Chef
![Page 21: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/21.jpg)
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
![Page 22: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/22.jpg)
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
![Page 23: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/23.jpg)
Logger MongoDB ! Recipe – fundamental configura=on unit in Chef
![Page 24: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/24.jpg)
Catalog MongoDB
![Page 25: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/25.jpg)
Chef Role ! Roles allow you to group recipes and a^ributes
![Page 26: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/26.jpg)
Ready to launch
! Chef configura=on is complete ! We’re now ready to launch the VM
! First, we’ll need to revisit the Vagranaile
![Page 27: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/27.jpg)
Updated Vagranaile
![Page 28: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/28.jpg)
Build and Provision the VM
![Page 29: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/29.jpg)
Verify MongoDB
![Page 30: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/30.jpg)
Connect to MongoDB
![Page 31: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/31.jpg)
Solu=on
! Use Vagrant + Chef to build and provision a local VM.
![Page 32: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/32.jpg)
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!
![Page 33: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/33.jpg)
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:
![Page 34: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/34.jpg)
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
![Page 35: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/35.jpg)
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…
![Page 36: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/36.jpg)
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
![Page 37: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/37.jpg)
Upcoming Shows
! Two great shows during Rails Conf ! Sunday Funday at Pier 6 ! Bonnaroo Buzz at Rams Head Live
![Page 38: Provisioning MongoDB)with) Vagrantand)Chef)files.meetup.com/347566/Bmore_On_Rails_Chef.pdf · 2011-04-15 · Provisioning MongoDB)with) Vagrantand)Chef) Nathen)Harvey) Web)Operaons,)](https://reader033.vdocuments.us/reader033/viewer/2022050415/5f8b9de47cb08054ef7e926c/html5/thumbnails/38.jpg)
Thank You!
! What ques=ons do you have?
Nathen Harvey
Web Opera=ons, CustomInk
Twi^er: @nathenharvey