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

Axispoint - A Taste of Chef Presentation

Axispoint - A Taste of Chef Presentation

Introduction to Chef and Infrastructure Automation for Axispoint Systems Group.

Avatar for rayrod2030

rayrod2030

June 06, 2012
Tweet

Other Decks in Programming

Transcript

  1. A TASTE OF CHEF An Introduction to Configuration Management and

    Infrastructure Automation with Chef Sunday, June 3, 12
  2. WHO ARE YOU? • System Administrators • Developers • Operations

    • Project leads and decision makers Sunday, June 3, 12
  3. WHAT ARE WE TALKING ABOUT? • Infrastructure as Code •

    Configuration Management • Systems Integration • Automation Sunday, June 3, 12
  4. HOW DO WE DO IT WITH SOFTWARE? What do we

    do when we need to recreate a deployable piece of software? Source Tools Workflow Sunday, June 3, 12
  5. BENEFITS OF INFRASTRUCTURE AS CODE • Repeatability • Automation •

    Agility • Scalability • Reassurance • Disaster Recovery Sunday, June 3, 12
  6. ENABLE THE RECONSTRUCTION OF THE BUSINESS FROM NOTHING BUT A

    SOURCE CODE REPOSITORY, AN APPLICATION DATA BACKUP, AND BARE METAL RESOURCES. Sunday, June 3, 12
  7. THE WILD WEST GETS WILDER • Effectively infinite computing power

    (Virtualization and Cloud) • Application stacks and their configuration are becoming increasingly more intricate • We increasingly get so bogged down in having to manage more and more complexity that we don’t have time to work on innovative solutions that add value to the company Sunday, June 3, 12
  8. WHAT IS CHEF? • Configuration Management Service • Provisioning Tool

    • Infrastructure Automation Framework Sunday, June 3, 12
  9. CHEF IN A NUTSHELL • Framework of libraries and primitives

    for building and managing infrastructure. • Tools that interact with the Chef API. Sunday, June 3, 12
  10. • RSA key authentication w/ signed Headers • RESTful API

    w/JSON • Search Service • Derivative Services THE CHEF API Sunday, June 3, 12
  11. THE CHEF COMMUNITY • Apache License, Version 2.0 • 360+

    Individual contributors • 70+ Corporate contributors • Dell, Rackspace, VMWare, RightScale, Heroku... • http://community.opscode.com • 240+ cookbooks • #chef on irc.freenode.net Sunday, June 3, 12
  12. TALKING LIKE A CHEF • Chef provides a Domain Specific

    Language syntax that is easy to understand and handles most tasks • When you need to go beyond the DSL you can code in pure Ruby without any restrictions • Many parts of Chef itself are written in Ruby • You don’t need to master Ruby. You need to know “just enough”. We’ll cover that in a later workshop. Sunday, June 3, 12
  13. HOW CHEF ENABLES INFRASTRUCTURE AS CODE • Resources • Recipes

    • Roles • Source Code package  “haproxy”  do action  :install end template  “/etc/haproxy/haproxy.cfg”  do source  “haproxy.cfg.erb” owner  “root” group  “root” mode  0644 notifies  :restart,  “service[haproxy]” end services  “haproxy”  do supports  :restart  =>  true action  [:enable,  :start] end Sunday, June 3, 12
  14. CHEF RESOURCES • Have a type • Have a name

    • Have parameters • Take action to put the resource in the declared state • Can send notifications to other resources package  “haproxy”  do action  :install end template  “/etc/haproxy/haproxy.cfg”  do source  “haproxy.cfg.erb” owner  “root” group  “root” mode  0644 notifies  :restart,  “service[haproxy]” end services  “haproxy”  do supports  :restart  =>  true action  [:enable,  :start] end Sunday, June 3, 12
  15. PACKAGE  “HAPROXY”     {yum  install  haproxy apt-­‐get  install  haproxy

    pacman  sync  haproxy pkg_add  -­‐r  haproxy Sunday, June 3, 12
  16. • Recipes are evaluated for resources in the order they

    appear. • Each resource object is added to the Resource Collection. package  “haproxy”  do action  :install end template  “/etc/haproxy/haproxy.cfg”  do source  “haproxy.cfg.erb” owner  “root” group  “root” mode  0644 notifies  :restart,  “service[haproxy]” end services  “haproxy”  do supports  :restart  =>  true action  [:enable,  :start] end CHEF RECIPES Sunday, June 3, 12
  17. • Recipes can include other recipes • Included recipes are

    process in order include_recipe  “apache2” include_recipe  “apache2::mod_rewrite” include_recipe  “apache2::mod_deflate” include_recipe  “apache2::mod_headers” include_recipe  “apache2::mod_php5” Sunday, June 3, 12
  18. • Extend recipes with Ruby • Iterate over an array

    of package names to install %w{  php5  php5-­‐dev  php5-­‐cgi  }.each  do  |pkg| package  pkg  do action  :install end end Sunday, June 3, 12
  19. • Good: Drop off a dynamic template • Better: Discover

    data through search template  “/etc/haproxy/haproxy.cfg”  do source  “haproxy.cfg.erb” owner  “root” group  “root” mode  0644 notifies  :restart,  “service[haproxy]” end pool_members  =  search(“node”,  “role:mediawiki”) template  “/etc/haproxy/haproxy.cfg.erb”  do source  “haproxy.cfg.erb” owner  “root” group  “root” mode  0644 variables  :pool_members  =>  pool_members notifies  :restart,  “service[haproxy]” end Sunday, June 3, 12
  20. • Roles describe nodes • Roles have a run list

    • Roles can have attributes name  “mediawiki” description  “mediawiki  app  server” run_list( “recipe[mysql::client]”, “recipe[application]”, “recipe[mediawiki::status]” ) name  “mediawiki_load_balancer” description  “mediawiki  load  balancer” run_list( “recipe[haproxy::app_lb]” ) override_attributes( “haproxy”  =>  { “app_server_role”  =>  “mediawiki” } ) CHEF ROLES Sunday, June 3, 12
  21. CHEF’S MENU FOR NEXT WEEK • Chef Server Architecture •

    Chef hosting options and Chef Solo • Anatomy of a Chef Run • Setting up your development environment (Windows, Linux, OS X) • knife skillz - Introduction to knife • Live Demo • Material will be more interactive and hands-on Sunday, June 3, 12