Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Automating Development Environments (Drupal Dev Days 2013)

Automating Development Environments (Drupal Dev Days 2013)

In this talk, I explained how we're using Chef to automate the setup of Vagrant VMs for our development environment freistilbox Solo.

3abfc9128fe1aeae3058edc36936f360?s=128

Jochen Lillich
PRO

June 30, 2013
Tweet

Transcript

  1. freistil.it Automating Development Environments Jochen Lillich

  2. About me

  3. Jochen Lillich @geewiz * 1970 Linux Sysadmin, Trainer, IT Manager

    Founder of freistil IT
  4. freistil IT http://freistil.it @freistil “Ops for Devs” freistilbox: Cluster-based PaaS

    for Drupal
  5. None
  6. Challenge... “Snowflake” development environments Manual configuration effort Mismatched software versions

    Long onboarding times
  7. ...accepted! Minimize setup time Make Development ≈ Production Reproduce setup

    consistently on demand
  8. Vagrant

  9. “Well, I’ve been doing that for ages with... •... snapshots!”

    •...VM images!” •...somethingorother!”
  10. None
  11. “No matter how complex the realities of your business, Chef

    makes it easy to deploy servers and scale applications throughout your entire infrastructure.” http://www.opscode.com/chef/
  12. Ruby DSL for system administration tasks Makes only necessary changes

    (Idempotence) CM with Chef
  13. Infrastructure as Code Cookbooks Recipes Resources Attributes Nodes Roles Providers

  14. Cookbook Bundles all the instructions for a certain service or

    system component. •Apache cookbook
  15. Recipe Defines what resources Chef needs to manage to reach

    a desired system state.
  16. Resource Package Service File, Directory Template Command, Script Cron Git

    ...
  17. Package, Service package ”apache2” do action :install end service ”apache2”

    do action [:enable, :start] end
  18. Template template ”/etc/apache2/apache2.conf” do source ”apache2.conf.erb” owner ”root” group ”root”

    mode 00644 notifies ”reload”, ”service[apache2]” end
  19. Attribute A value used in resource definitions that can differ

    from node to node. •PHP memory limit •Number of CPU’s
  20. Role Defines •a runlist of recipes/roles •a set of default

    attributes
  21. Community sites http://wiki.opscode.com http://community.opscode.com http://github.com/opscode-cookbooks

  22. +

  23. Preparations Install VirtualBox •http://f7it.com/virtualboxdl Install Vagrant •http://f7it.com/vagrantdl

  24. Vagrant $ mkdir drupaldev $ cd drupaldev $ vagrant init

    precise32 \ http://files.vagrantup.com/precise32.box $ vagrant up
  25. Caching $ vagrant plugin install vagrant-cachier config.cache.auto_detect = true

  26. Cookbooks $ gem install librarian-chef $ librarian-chef init site ”http://community.opscode.com/api/v1”

    cookbook 'apt', '= 1.10.0' cookbook 'apache2' cookbook 'php' cookbook 'mysql' $ librarian-chef install
  27. Role name "drupal" description "Drupal dev VM" run_list( "recipe[apache2]", "recipe[apache2::mod_expires]",

    "recipe[apache2::mod_rewrite]", "recipe[apache2::mod_php5]", "recipe[php]", "recipe[php::module_mysql]", "recipe[mysql::client]", "recipe[mysql::server]" )
  28. Role (cont.) default_attributes({ 'mysql' => { 'server_debian_password' => 's3cr3t', 'server_root_password'

    => 's3cr3t', 'server_repl_password' => 's3cr3t' } })
  29. Provisioning config.vm.provision :chef_solo do |chef| chef.cookbooks_path = ”cookbooks” chef.roles_path =

    ”roles” chef.add_role ”drupal” end $ vagrant reload $ vagrant provision
  30. Now do some awesome stuff!

  31. And finally... $ vagrant destroy

  32. Tips Keep all building blocks local: •Cache packages •Store your

    own base boxes •Use a central cookbook repository
  33. Conclusion Combining Vagrant and Chef gives us: •Dedicated, consistent, disposable

    dev setups •Efficient onboarding of new devs
  34. freistilbox Solo http://f7it.com/ddd13

  35. Thank you! Questions?