Chef & Vagrant
Automate server builds
The Old Way
● Provision Server
● Install packages
– Apt-get
– Install from source
– Perl/Bash scripts scripts
● Not very s...
The New Way
● Provision Server
● Run Chef to configure
● Highly scalable
● Very modular
● Recipes are Ruby DSL, checked in...
Getting Started - the Parts
● VirtualBox
– Open Source virtualization software
● Chef (Solo)
– Framework for configuring s...
Getting Started
● Download and Install:
– VirtualBox: https://www.virtualbox.org/wiki/Downloads
– Vagrant: http://download...
Create the first VM
● Create an Ubuntu 12.04 server
● Install Apache2
● Install MySql server 5.5
Create new VM
● example
Key Vagrant Commands
● vangrant init – generate Vagrant configuration file
● vagrant up – start VM
● vagrant halt – stop V...
What does Chef do?
● Allows you to describe the state of a server
● Only acts if the system reflects a different state
● P...
Install Apache, MySQL
● Back to Example
Resources
● A piece of the system and it's desired state
● Ex:
directory "/tmp/folder" do
owner "root"
group "root"
mode 0...
More Resources
● And when all else fails:
● Full list online http://docs.opscode.com/resource.html
bash "install_something...
Anatomy of a Cookbook
● attributes – default values
● recipes – actual steps to perform
● files – static files, usually co...
Getting Cookbooks
● Opscode: http://community.opscode.com/cookbooks
● GitHub:
– Opscode's: https://github.com/opscode-cook...
Recipe Run
● Always runs recipes/default.rb
● If you've specified another recipe, run that one: for
example:
– mysql:serve...
More Complicated Example: ESB
● Run through the ESB setup
Final Thoughts
● Chef is not the end all, but another tool in your toolbox
● Good for system configuration documentation
●...
Questions?
Upcoming SlideShare
Loading in...5
×

Chef, Vagrant, and VirtualBox

977

Published on

Basic overview of Chef, Vagrant, and VirtualBox for building development environments.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
977
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
29
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Chef, Vagrant, and VirtualBox

  1. 1. Chef & Vagrant Automate server builds
  2. 2. The Old Way ● Provision Server ● Install packages – Apt-get – Install from source – Perl/Bash scripts scripts ● Not very scalable ● Can't version control your servers ● Hard to fully automate
  3. 3. The New Way ● Provision Server ● Run Chef to configure ● Highly scalable ● Very modular ● Recipes are Ruby DSL, checked into Git ● Can be fully automated with minimal effort
  4. 4. Getting Started - the Parts ● VirtualBox – Open Source virtualization software ● Chef (Solo) – Framework for configuring servers – Write your recipes in Ruby ● Vagrant – virtualization wrapper for VirtualBox, VMWare, AWS, etc. – Allows you to bootstrap with Chef (or Puppet)
  5. 5. Getting Started ● Download and Install: – VirtualBox: https://www.virtualbox.org/wiki/Downloads – Vagrant: http://downloads.vagrantup.com/ ● Checkout Gazelle cookbooks: – git clone --recursive https://github.com/secondrotation/secondrotation_chef.git – (Make sure you use recursive so you get the submodules)
  6. 6. Create the first VM ● Create an Ubuntu 12.04 server ● Install Apache2 ● Install MySql server 5.5
  7. 7. Create new VM ● example
  8. 8. Key Vagrant Commands ● vangrant init – generate Vagrant configuration file ● vagrant up – start VM ● vagrant halt – stop VM ● vagrant reload – restart VM (stop, start) ● vagrant ssh – log into VM ● vagrant –help
  9. 9. What does Chef do? ● Allows you to describe the state of a server ● Only acts if the system reflects a different state ● Provides a generic abstraction layer with access to key attributes (os, hardware, etc.) ● Runs actions in the order you specified (unlike Puppet) ● Power of Ruby – arrays, looping, logic, Erb templates, blocks, etc. - It's familiar
  10. 10. Install Apache, MySQL ● Back to Example
  11. 11. Resources ● A piece of the system and it's desired state ● Ex: directory "/tmp/folder" do owner "root" group "root" mode 0755 action :create end remote_file "#{Chef::Config[:file_cache_path]}/large-file.tar.gz" do source "http://www.example.org/large-file.tar.gz" end package "git" do action :install end
  12. 12. More Resources ● And when all else fails: ● Full list online http://docs.opscode.com/resource.html bash "install_something" do user "root" cwd "/tmp" code <<-EOH wget http://www.example.com/tarball.tar.gz tar -zxf tarball.tar.gz cd tarball ./configure make make install EOH end
  13. 13. Anatomy of a Cookbook ● attributes – default values ● recipes – actual steps to perform ● files – static files, usually configuration ● templates – dynamic files, unusually Erb templates used for configuration ● definitions – custom resources specific to that cookbook ● tests – Cucumber & MiniTest, TestKitchen
  14. 14. Getting Cookbooks ● Opscode: http://community.opscode.com/cookbooks ● GitHub: – Opscode's: https://github.com/opscode-cookbooks (135) – Other People's cookbooks: check out code before using – Fork and give back!
  15. 15. Recipe Run ● Always runs recipes/default.rb ● If you've specified another recipe, run that one: for example: – mysql:server: ● First runs recipes/default.rb ● Then runs recipes/server.rb ● It's easy to write spaghetti code – Refactor, refactor, refactor
  16. 16. More Complicated Example: ESB ● Run through the ESB setup
  17. 17. Final Thoughts ● Chef is not the end all, but another tool in your toolbox ● Good for system configuration documentation ● VM based approach is slow to run for a variety of reasons – apt-get runs as a single thread – Compiling code is generally slow ● Docker is an interesting alternative to traditional VM, but not ready for production
  18. 18. Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×