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

Vagrant and Chef for Rails Developers

Martin Fenner
September 05, 2014

Vagrant and Chef for Rails Developers

Rails Software Development with Chef and Vagrant

Martin Fenner

September 05, 2014
Tweet

More Decks by Martin Fenner

Other Decks in Technology

Transcript

  1. Rails Software Development !
    with Chef and Vagrant
    !
    !
    !
    !
    !
    !
    !
    !
    !
    Martin Fenner
    Technical Lead, PLOS Article-Level Metric Project
    https://github.com/mfenner
    http://en.wikipedia.org/wiki/Chef

    View Slide

  2. https://github.com/articlemetrics/alm-report

    View Slide

  3. http://www.flickr.com/photos/jeffhester/77728574/
    Dev/Prod Parity
    Keep development, staging, and production as similar as possible!
    http://12factor.net/dev-prod-parity

    View Slide

  4. Dev Environment == Production
    Then you can’t develop on a Mac?

    View Slide

  5. Bundler provides a consistent environment for
    Ruby projects by tracking and installing the
    exact gems and versions that are needed.
    RVM is a command-line tool which allows you to
    easily install, manage, and work with multiple ruby
    environments from interpreters to sets of gems.
    Homebrew installs the stuff you need that Apple
    didn’t.
    RubyGems is a package manager for the Ruby
    language.
    Good, but not good enough

    View Slide

  6. These two make a difference
    Automation
    Virtualization
    http://en.wikipedia.org/wiki/Max_and_Moritz

    View Slide

  7. 3
    Dev Environment == Production
    Automation!
    Shell!
    Ansible!
    CFEngine!
    Chef!
    Puppet!
    Salt!
    Docker
    Virtualization!
    Virtualbox!
    VMware!
    AWS!
    Rackspace!
    Digital Ocean!
    Hyper-V!
    Docker
    https://www.vagrantup.com/
    Vagrant is a tool for building complete
    development environments

    View Slide

  8. Dev Environment == Production
    https://xkcd.com/

    View Slide

  9. Dev Environment == Production
    https://xkcd.com/
    Vagrant Core Concepts
    Code and configuration management is under
    version control. Clone a repo and get started.
    Shared Folders
    Host and guest Virtual Machine share access to the
    project code. Use your favorite editor for
    development and see changes immediately.
    Keep it Simple Dramatically reduce the learning curve to configure
    a Virtual Machine and run IT automation software.
    No Vendor Lock-in
    Open source software (VMware plugin is
    commercial). Flexibility in virtualization and
    automation tools.

    View Slide

  10. The Future!
    But not much help for developing single web
    applications on a Mac
    https://www.docker.com/

    View Slide

  11. https://downloads.getchef.com/chef-dk

    View Slide

  12. https://downloads.getchef.com/chef-dk
    A cookbook is the fundamental unit of configuration
    and policy distribution.!
    !
    Cookbooks are written in Ruby, using the Chef DSL.!
    !
    The Chef Supermarket is the central community
    resource for cookbooks.!
    https://supermarket.getchef.com/!
    !
    Berkshelf and Librarian-Chef are two popular tools
    to manage cookbook installation and dependencies.!
    http://berkshelf.com/!
    https://github.com/applicationsonline/librarian-chef!
    Chef Cookbooks

    View Slide

  13. Dev Environment == Production
    Chef Recipes
    https://github.com/articlemetrics/alm_report-cookbook
    This recipe installs and configures the ALM Reports
    Ruby on Rails application.

    View Slide

  14. Dev Environment == Production
    https://github.com/articlemetrics/mysql_rails-cookbook/blob/master/providers/default.rb
    Chef Resource (LWRP)
    Trend is to use resources instead of recipes.

    View Slide

  15. Dev Environment == Production
    Chef Attributes
    https://github.com/articlemetrics/ruby-cookbook/blob/master/attributes/default.rb
    Although there many standard cookbooks, best
    practices are still emerging.

    View Slide

  16. http://kitchen.ci/
    Test Kitchen

    View Slide

  17. Dev Environment == Production
    Serverspec
    https://github.com/articlemetrics/passenger_nginx-cookbook/blob/master/test/integration/default/serverspec/nginx_spec.rb
    Test-driven development for infrastructure code.

    View Slide

  18. Dev Environment == Production
    Further Reading
    Pivotal Sprout!
    Chef recipe to configure an OS X Mavericks developer workstation!
    https://github.com/pivotal-sprout
    Customizing Chef!
    Chef for cookbook authors. August 2014!
    http://shop.oreilly.com/product/0636920032984.do
    Vagrant Blog!
    Feature Preview: Docker-Based Development Environments!
    https://www.vagrantup.com/blog/feature-preview-vagrant-1-6-
    docker-dev-environments.htm

    View Slide