Config managament for development environments iii
Upcoming SlideShare
Loading in...5
×
 

Config managament for development environments iii

on

  • 2,624 views

Gareth rushgrove

Gareth rushgrove

Statistics

Views

Total Views
2,624
Views on SlideShare
2,624
Embed Views
0

Actions

Likes
5
Downloads
73
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Config managament for development environments iii Config managament for development environments iii Presentation Transcript

  • Configuration Managementfor Development EnvironmentsPuppetConf 22nd September 2011gareth rushgrove | morethanseven.net http://www.flickr.com/photos/36144637@N00/159627088/
  • Gareth Rushgrovegareth rushgrove | morethanseven.net
  • Work at UK Government Digital Servicegareth 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/5059217055
  • 1. Sysadmins don’t want devs to be sysadminsgareth rushgrove | morethanseven.net http://www.flickr.com/photos/34652102@N04/5059217055
  • 2. New team members getting started timegareth rushgrove | morethanseven.net http://www.flickr.com/photos/34652102@N04/5059824808
  • 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 Version: 5.1.41-3ubuntu12.10Homebrew is great but...gareth rushgrove | morethanseven.net
  • 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
  • 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" ⚡ lsOn our Macgareth rushgrove | morethanseven.net
  • ⚡ ./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
  • $ ./server.rb & $ curl "http://127.0.0.1:8181/?query=Bob" $ curl "http://127.0.0.1:8181/?query=bob" $ lsOn Linuxgareth rushgrove | morethanseven.net
  • $ ./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
  • 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 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
  • 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 upgareth rushgrove | morethanseven.net
  • ⚡ ls Vagrantfile ⚡ vagrant up ⚡ vagrant ssh ⚡ vagrant reload ⚡ vagrant halt ⚡ vagrant destroyVagrant command linegareth rushgrove | morethanseven.net
  • ⚡ 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
  • Vagrant::Config.run do |config| config.vm.box = "lucid32" endVagrantfilegareth rushgrove | morethanseven.net
  • 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
  • Vagrant::Config.run do |config| config.vm.share_folder("folder", "/guest", "../host") endShared foldersgareth rushgrove | morethanseven.net
  • 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
  • Vagrant::Config.run do |config| config.vm.boot_mode = :gui config.ssh.forward_agent = true config.vm.network("33.33.33.10") config.vm.customize do |vm| vm.memory_size = 512 end endLots more optionsgareth rushgrove | morethanseven.net
  • Puppetgareth rushgrove | morethanseven.net
  • 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
  • Vagrant::Config.run do |config| config.vm.provision :puppet_server do |puppet| puppet.puppet_server = "puppet.example.com" puppet.puppet_node = "vm.example.com" end endVagrant provisioning with Puppetmastergareth rushgrove | morethanseven.net
  • Chefgareth rushgrove | morethanseven.net
  • 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
  • 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
  • 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
  • - 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
  • ⚡ vagrant provision [default] Running provisioner: Vagrant::Provisioners::Puppet... [default] Running Puppet with base.pp... [default] notice: /Stage[main]//File[/etc/motd]/ content: content changed {md5} a10cc0046a5fad11470513e5f5df9d91 to {md5} 9e5e449fc643d3e88a2cefeb1af7bc2e [default] [default] notice: /Stage[main]//File[/etc/motd]/ mode: mode changed 777 to 644Useful for testing puppet modulesgareth rushgrove | morethanseven.net
  • Useful for local configuration managementgareth rushgrove | morethanseven.net http://www.flickr.com/photos/crustyscumbrothersontour/2674351601
  • - I want my development environment on my local vms- I don’t want a wiki page of instructions- I don’t want to have to manually install anything- I don’t want to care about destroying a virtual machineReal world examplegareth rushgrove | morethanseven.net
  • ⚡ tree ├── Vagrantfile └── modules └── garethr ├── manifests │   └── init.pp ├── spec │   └── classes │   └── base.rv │   └── janus.rv │   └── ohmyzsh.rv └────── spec_helper.rbPuppet layoutgareth rushgrove | morethanseven.net
  • class base { $packages = ["zsh", "wget", "curl", "lynx", "git-core", "dvtm", “tree”, "build-essential", "vim-nox"] package { $packages: ensure => "installed" } }Packages I likegareth rushgrove | morethanseven.net
  • $repo = "git://github.com/robbyrussell/oh-my-zsh.git" exec { "ohmyzsh": command => "git clone ${repo} .oh-my-zsh", cwd => "/home/vagrant", creates => "/home/vagrant/.oh-my-zsh", require => Class["base"], } exec { "zshrc": command => "cp .... /home/vagrant/.zshrc", creates => "/home/vagrant/.zshrc", require => Exec["ohmyzsh"], }My Zsh configsgareth rushgrove | morethanseven.net
  • $repo = "git://github.com/carlhuda/janus.git" exec { "get_janus": command => "git clone ${repo} .vim", cwd => "/home/vagrant", creates => "/home/vagrant/.vim", require => Class["base"], } exec { "compile_janus": command => "rake", creates => "/home/vagrant/.zshrc", require => Exec["ohmyzsh"], environment => "HOME=/home/vagrant", }My Vim configsgareth rushgrove | morethanseven.net
  • require spec_helper describe ohmyzsh, :type => :class do it { should create_exec("ohmyzsh") } it { should create_exec("zshrc") } it { should create_class("base") } endTesting with Rspecgareth rushgrove | morethanseven.net
  • base should create Package[zsh] should create Package[vim-nox] should create Package[git-core] ohmyzsh should create Exec[ohmyzsh] should create Exec[zshrc] should create Class[base] Finished in 1.4 seconds 10 examples, 0 failuresRspec resultsgareth rushgrove | morethanseven.net
  • - Using Virtualisation makes getting started fast- Running the same platform catches bugs early- Using Vagrant makes managing virtual machines easy- Writing configuration as code makes it testableConclusionsgareth rushgrove | morethanseven.net
  • - IRC - #vagrant on Freenode- Github Issues - https://github.com/mitchellh/vagrant/issues- Google Groups - http://groups.google.com/group/vagrant-upMore information on Vagrantgareth rushgrove | morethanseven.net
  • Questions?gareth rushgrove | morethanseven.net http://flickr.com/photos/psd/102332391/