Configuration Managementfor Development EnvironmentsLRUG 8th August 2011gareth rushgrove | morethanseven.net   http://www.fl...
Gareth Rushgrovegareth rushgrove | morethanseven.net
Blog at morethanseven.netgareth rushgrove | morethanseven.net
Curate devopsweekly.comgareth rushgrove | morethanseven.net
Problemsgareth rushgrove | morethanseven.net   http://www.flickr.com/photos/iancarroll/5027441664
1. Not all developers want to be sysadminsgareth rushgrove | morethanseven.net   http://www.flickr.com/photos/34652102@N04/...
2. New team members getting started timegareth rushgrove | morethanseven.net   http://www.flickr.com/photos/34652102@N04/50...
3. Running a full set of services locallygareth rushgrove | morethanseven.net        http://www.flickr.com/photos/biggreymare
4. Works on my machinegareth rushgrove | morethanseven.net
⚡ brew info mysql      mysql 5.5.14      $ aptitude show mysql-server      Package: mysql-server      State: not installed...
23 releases and 21 months in-between 5.1.41 and 5.5.14. Here’s some fixed bugs: -      An ORDER BY clause was bound to the ...
Spot the cross platform bug (not the security flaw)gareth rushgrove | morethanseven.net
⚡ ./server.rb &      ⚡ curl "http://127.0.0.1:8181/?query=Bob"      ⚡ curl "http://127.0.0.1:8181/?query=bob"      ⚡ ls   ...
$ ./server.rb &      $ curl "http://127.0.0.1:8181/?query=Bob"      $ curl "http://127.0.0.1:8181/?query=bob"      $ ls   ...
Solutionsgareth rushgrove | morethanseven.net   http://www.flickr.com/photos/34652102@N04/5059208501
Virtualisationgareth rushgrove | morethanseven.net   http://www.flickr.com/photos/dawilson/2598713027
VirtualBoxgareth rushgrove | morethanseven.net
VMwaregareth rushgrove | morethanseven.net
Virtualisation needs powerful hardwaregareth rushgrove | morethanseven.net   http://www.flickr.com/photos/martinoc/477335951
What about editing code?gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/peteradams/2272928740
Shared Folders or NFSgareth rushgrove | morethanseven.net   http://www.flickr.com/photos/34652102@N04/5059846582
Doubledown
Vimgareth rushgrove | morethanseven.net
Vagrantup.comgareth rushgrove | morethanseven.net
-      Automated virtual machine creation using Oracle’s VirtualBox-      Automated provisioning of virtual environments u...
Base boxesgareth rushgrove | morethanseven.net   http://www.flickr.com/photos/dawilson/2793319903
VeeWeegareth rushgrove | morethanseven.net
Community boxesgareth rushgrove | morethanseven.net
⚡ gem install vagrant      ⚡ vagrant box add lucid32 http://.../lucid32.box      ⚡ vagrant init      ⚡ vagrant upVagrant u...
⚡ ls   Vagrantfile   ⚡ vagrant up   ⚡ vagrant ssh   ⚡ vagrant reload   ⚡ vagrant halt   ⚡ vagrant destroyVagrant command l...
⚡ vagrant ssh-config   Host default     HostName 127.0.0.1     User vagrant     Port 2222     IdentityFile /Users/.../vagr...
Vagrant::Config.run do |config|              config.vm.box = "lucid32"            endVagrantfilegareth rushgrove | morethan...
Vagrant::Config.run do |config|     config.vm.forward_port("web", 80, 8080)     config.vm.forward_port("ftp", 21, 4567)   ...
Vagrant::Config.run do |config|     config.vm.share_folder("folder", "/guest", "../host")   endShared foldersgareth rushgr...
Vagrant::Config.run do |config|     config.vm.define :web do |web_config|       web_config.vm.box = "web"       web_config...
Vagrant::Config.run do |config|     config.vm.boot_mode      = :gui     config.ssh.forward_agent = true     config.vm.cust...
Puppetgareth rushgrove | morethanseven.net
Vagrant::Config.run do |config|               config.vm.provision :puppet do |puppet|                 puppet.manifests_pat...
Chefgareth rushgrove | morethanseven.net
Vagrant::Config.run do |config|               config.vm.provision :chef_solo do |chef|                 chef.add_recipe    ...
Vagrant::Config.run do |config|               config.vm.provision :chef_solo do |chef|                 chef.roles_path = "...
Vagrant::Config.run do |config|   config.vm.provision :chef_solo do |chef|     chef.recipe_url = "http://github.com/cookbo...
-      Vagrant Hosts - https://github.com/dwt/vagrant-hosts-      Sahara - https://github.com/jedi4ever/sahara-      Vagra...
Local configuration managementgareth rushgrove | morethanseven.net   http://www.flickr.com/photos/crustyscumbrothersontour/2...
-      I want my development environment everywhere-      I don’t want a wiki page of instructions-      I don’t want to h...
⚡ cd /m/somefolder   ⚡ tree   ├── Vagrantfile   └── cookbooks       └── garethr           ├── attributes           │   └──...
%w{zsh wget curl lynx             git-core ack-grep vim-nox             dvtm build-essential tree}.each do |pkg|          ...
git "/home/vagrant/.oh-my-zsh" do                repository node[:garethr][:ohmyzsh]                action :checkout      ...
default[:garethr][:dotvim] =             "https://github.com/carlhuda/janus.git"          default[:garethr][:ohmyzsh] =   ...
git "/home/vagrant/.vim" do                repository node[:garethr][:dotvim]                action :checkout             ...
require "chefspec"              describe "garethr" do                before(:all) do                  @chef_run = ChefSpec...
-      The Chef Server-      Roles and Environments-      Knife and Shef-      Splitting the one file into multiple cookboo...
-      Using Virtualisation catches bugs early-      Using Vagrant makes using virtual machines pleasurable-      Storing ...
-      IRC - #vagrant on Freenode-      Github Issues - https://github.com/mitchellh/vagrant/issues-      Google Groups - ...
Questions?gareth rushgrove | morethanseven.net   http://flickr.com/photos/psd/102332391/
Upcoming SlideShare
Loading in...5
×

Config managament for development environments ii

3,557

Published on

Talk for the London Ruby User Group about using configuration management tools to manage development environments. Lots of Vagrant and Chef code examples.

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

No Downloads
Views
Total Views
3,557
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
83
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide

Config managament for development environments ii

  1. 1. Configuration Managementfor Development EnvironmentsLRUG 8th August 2011gareth rushgrove | morethanseven.net http://www.flickr.com/photos/36144637@N00/159627088/
  2. 2. Gareth Rushgrovegareth rushgrove | morethanseven.net
  3. 3. Blog at morethanseven.netgareth rushgrove | morethanseven.net
  4. 4. Curate devopsweekly.comgareth rushgrove | morethanseven.net
  5. 5. Problemsgareth rushgrove | morethanseven.net http://www.flickr.com/photos/iancarroll/5027441664
  6. 6. 1. Not all developers want to be sysadminsgareth rushgrove | morethanseven.net http://www.flickr.com/photos/34652102@N04/5059217055
  7. 7. 2. New team members getting started timegareth rushgrove | morethanseven.net http://www.flickr.com/photos/34652102@N04/5059824808
  8. 8. 3. Running a full set of services locallygareth rushgrove | morethanseven.net http://www.flickr.com/photos/biggreymare
  9. 9. 4. Works on my machinegareth rushgrove | morethanseven.net
  10. 10. ⚡ brew info mysql mysql 5.5.14 $ aptitude show mysql-server Package: mysql-server State: not installed Version: 5.1.41-3ubuntu12.10Homebrew is great but...gareth rushgrove | morethanseven.net
  11. 11. 23 releases and 21 months in-between 5.1.41 and 5.5.14. Here’s some fixed bugs: - An ORDER BY clause was bound to the incorrect substatement when used in UNION context. - A NOT IN predicate with a subquery containing a HAVING clause could retrieve too many rows, when the subquery itself returned NULL. - MIN(year_col) could return an incorrect result in some cases. And lots moreWhat’s a few versions between friends?gareth rushgrove | morethanseven.net
  12. 12. Spot the cross platform bug (not the security flaw)gareth rushgrove | morethanseven.net
  13. 13. ⚡ ./server.rb & ⚡ curl "http://127.0.0.1:8181/?query=Bob" ⚡ curl "http://127.0.0.1:8181/?query=bob" ⚡ ls Bob ⚡ cat Bob Hello bobOn our Macgareth rushgrove | morethanseven.net
  14. 14. $ ./server.rb & $ curl "http://127.0.0.1:8181/?query=Bob" $ curl "http://127.0.0.1:8181/?query=bob" $ ls Bob bob $ cat Bob Hello Bob $ cat bob Hello bobOn Linuxgareth rushgrove | morethanseven.net
  15. 15. Solutionsgareth rushgrove | morethanseven.net http://www.flickr.com/photos/34652102@N04/5059208501
  16. 16. Virtualisationgareth rushgrove | morethanseven.net http://www.flickr.com/photos/dawilson/2598713027
  17. 17. VirtualBoxgareth rushgrove | morethanseven.net
  18. 18. VMwaregareth rushgrove | morethanseven.net
  19. 19. Virtualisation needs powerful hardwaregareth rushgrove | morethanseven.net http://www.flickr.com/photos/martinoc/477335951
  20. 20. What about editing code?gareth rushgrove | morethanseven.net http://www.flickr.com/photos/peteradams/2272928740
  21. 21. Shared Folders or NFSgareth rushgrove | morethanseven.net http://www.flickr.com/photos/34652102@N04/5059846582
  22. 22. Doubledown
  23. 23. Vimgareth rushgrove | morethanseven.net
  24. 24. Vagrantup.comgareth rushgrove | morethanseven.net
  25. 25. - Automated virtual machine creation using Oracle’s VirtualBox- Automated provisioning of virtual environments using Chef or Puppet- Full SSH access to created environments- Assign a static IP to your VM, accessible from your machine- Forward ports to the host machine- Shared folders allows you to continue using your own editor- Package environments into distributable boxes- Completely tear down environment when you’re done- Easily rebuild a complete environment with a single commandWhat is Vagrant?gareth rushgrove | morethanseven.net
  26. 26. Base boxesgareth rushgrove | morethanseven.net http://www.flickr.com/photos/dawilson/2793319903
  27. 27. VeeWeegareth rushgrove | morethanseven.net
  28. 28. Community boxesgareth rushgrove | morethanseven.net
  29. 29. ⚡ gem install vagrant ⚡ vagrant box add lucid32 http://.../lucid32.box ⚡ vagrant init ⚡ vagrant upVagrant upgareth rushgrove | morethanseven.net
  30. 30. ⚡ ls Vagrantfile ⚡ vagrant up ⚡ vagrant ssh ⚡ vagrant reload ⚡ vagrant halt ⚡ vagrant destroyVagrant command linegareth rushgrove | morethanseven.net
  31. 31. ⚡ vagrant ssh-config Host default HostName 127.0.0.1 User vagrant Port 2222 IdentityFile /Users/.../vagrant-0.8.2/keys/vagrant ...Export SSH configurationgareth rushgrove | morethanseven.net
  32. 32. Vagrant::Config.run do |config| config.vm.box = "lucid32" endVagrantfilegareth rushgrove | morethanseven.net
  33. 33. Vagrant::Config.run do |config| config.vm.forward_port("web", 80, 8080) config.vm.forward_port("ftp", 21, 4567) config.vm.forward_port("ssh", 22, 2222, :auto => true) endPort forwardinggareth rushgrove | morethanseven.net
  34. 34. Vagrant::Config.run do |config| config.vm.share_folder("folder", "/guest", "../host") endShared foldersgareth rushgrove | morethanseven.net
  35. 35. Vagrant::Config.run do |config| config.vm.define :web do |web_config| web_config.vm.box = "web" web_config.vm.forward_port("http", 80, 8080) end config.vm.define :db do |db_config| db_config.vm.box = "db" db_config.vm.forward_port("db", 3306, 3306) end endMultiple VMs in one filegareth rushgrove | morethanseven.net
  36. 36. Vagrant::Config.run do |config| config.vm.boot_mode = :gui config.ssh.forward_agent = true config.vm.customize do |vm| vm.memory_size = 512 end endLots more optionsgareth rushgrove | morethanseven.net
  37. 37. Puppetgareth rushgrove | morethanseven.net
  38. 38. Vagrant::Config.run do |config| config.vm.provision :puppet do |puppet| puppet.manifests_path = "puppetmanifests" puppet.manifest_file = "newbox.pp" end endVagrant provisioning with Puppetgareth rushgrove | morethanseven.net
  39. 39. Chefgareth rushgrove | morethanseven.net
  40. 40. Vagrant::Config.run do |config| config.vm.provision :chef_solo do |chef| chef.add_recipe = "garethr" chef.cookbooks_path = “cookbooks” end endVagrant provisioning with Chefgareth rushgrove | morethanseven.net
  41. 41. Vagrant::Config.run do |config| config.vm.provision :chef_solo do |chef| chef.roles_path = "roles" chef.add_role("vm") end endSpecifying Chef rolesgareth rushgrove | morethanseven.net
  42. 42. Vagrant::Config.run do |config| config.vm.provision :chef_solo do |chef| chef.recipe_url = "http://github.com/cookbooks.tar.gz" chef.add_recipe "garethr" chef.cookbooks_path = [:vm, "cookbooks"] chef.json.merge!({ :garethr => { :ohmyzsh => "https://github.com/.../oh-my-zsh.git", :dotvim => "https://github.com/garethr/dotvim.git" }}) end endRemote filegareth rushgrove | morethanseven.net
  43. 43. - Vagrant Hosts - https://github.com/dwt/vagrant-hosts- Sahara - https://github.com/jedi4ever/sahara- Vagrantboxes - https://github.com/garethr/ruby-vagrantboxesPluginsgareth rushgrove | morethanseven.net http://www.flickr.com/photos/s3a/4710416678
  44. 44. Local configuration managementgareth rushgrove | morethanseven.net http://www.flickr.com/photos/crustyscumbrothersontour/2674351601
  45. 45. - I want my development environment everywhere- I don’t want a wiki page of instructions- I don’t want to have to manually install everything- I don’t want to care about destroying a virtual machine- So I have a simple Chef cookbook to bootstrap my machinesReal world examplegareth rushgrove | morethanseven.net
  46. 46. ⚡ cd /m/somefolder ⚡ tree ├── Vagrantfile └── cookbooks └── garethr ├── attributes │   └── default.rb ├── files │   └── default │   └── zshrc └── recipes └── default.rbChef cookbook layoutgareth rushgrove | morethanseven.net
  47. 47. %w{zsh wget curl lynx git-core ack-grep vim-nox dvtm build-essential tree}.each do |pkg| package pkg do action :install end endPackages I likegareth rushgrove | morethanseven.net
  48. 48. git "/home/vagrant/.oh-my-zsh" do repository node[:garethr][:ohmyzsh] action :checkout user "vagrant" group "vagrant" end cookbook_file "/home/vagrant/.zshrc" do source "zshrc" owner "vagrant" group "vagrant" endMy shell configsgareth rushgrove | morethanseven.net
  49. 49. default[:garethr][:dotvim] = "https://github.com/carlhuda/janus.git" default[:garethr][:ohmyzsh] = "https://github.com/robbyrussell/oh-my-zsh.git"Attributesgareth rushgrove | morethanseven.net
  50. 50. git "/home/vagrant/.vim" do repository node[:garethr][:dotvim] action :checkout user "vagrant" end execute "build janus" do command "rake" user "vagrant" cwd "/home/vagrant/.vim" environment ({HOME => /home/vagrant}) creates "/home/vagrant/.vimrc" endMy Vim configsgareth rushgrove | morethanseven.net
  51. 51. require "chefspec" describe "garethr" do before(:all) do @chef_run = ChefSpec::ChefRunner.new @chef_run.converge "garethr" end it "should install zsh" do @chef_run.should install_package "zsh" end endTesting with ChefSpecgareth rushgrove | morethanseven.net
  52. 52. - The Chef Server- Roles and Environments- Knife and Shef- Splitting the one file into multiple cookbooks- Managing running services- Simplifying cookbooks by creating system packages- Supporting different operating systems- The Chef architecture- Testing with Cucumber-ChefAwesome things I ignoredgareth rushgrove | morethanseven.net
  53. 53. - Using Virtualisation catches bugs early- Using Vagrant makes using virtual machines pleasurable- Storing configuration as code makes it shareable- Able to apply development best practice to dev environmentsConclusionsgareth rushgrove | morethanseven.net
  54. 54. - IRC - #vagrant on Freenode- Github Issues - https://github.com/mitchellh/vagrant/issues- Google Groups - http://groups.google.com/group/vagrant-upMore informationgareth rushgrove | morethanseven.net
  55. 55. Questions?gareth rushgrove | morethanseven.net http://flickr.com/photos/psd/102332391/
  1. A particular slide catching your eye?

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

×