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

DevOps: Puppet & Chef

James Tan
October 21, 2012

DevOps: Puppet & Chef

Overview on DevOps, Puppet & Chef, as well as a comparison between the two.

James Tan

October 21, 2012
Tweet

More Decks by James Tan

Other Decks in Technology

Transcript

  1. 0 10 20 30 40 50 60 susestudio.com deployments (per

    month) Jun 2009 to Sep 2012 Deployments Continuous deployments!
  2. What happens when the server crashes? How do you scale

    this to other servers? How do you deploy to other data centers or to the cloud?
  3. vs

  4. Installing on openSUSE 12.2 # Installing Puppet > zypper ar

    http://download.opensuse.org/repositories\ /systemsmanagement:/puppet/openSUSE_12.2/ Puppet > zypper in puppet # Installing Chef > zypper ar http://download.opensuse.org/repositories\ /systemsmanagement:/chef/openSUSE_12.2/ Chef > zypper in rubygem-chef
  5. Puppet quickstart (serverless) > vim test.pp file { 'testfile-puppet': path

    => '/tmp/testfile-puppet', ensure => present, mode => '0640', content => "I'm a test file.\n" } > puppet apply test.pp
  6. Chef quickstart (solo) > knife cookbook create test > vim

    /var/chef/cookbooks/test/recipes/default.rb file "/tmp/testfile-chef" do mode "0640" content "I'm a test file.\n" action :create end > chef-solo -o test -N test
  7. Puppet package, file, service package { 'openssh-server': ensure => present,

    before => File['/etc/ssh/sshd_config'] } file { '/etc/ssh/sshd_config': ensure => file, mode => '0600', source => 'sshd_config' } service { 'sshd': ensure => running, enable => true, hasrestart => true, hasstatus => true, subscribe => File['/etc/ssh/sshd_config'] } Ensure order!
  8. Chef package, file, service package "openssh-server" do action :install end

    cookbook_file "/etc/ssh/sshd_config" do source "sshd_config" mode "0600" end service "sshd" do supports :status => true, :restart => true action [ :enable, :start ] subscribes :reload, resources( "cookbook_file[/etc/ssh/sshd_config]") end
  9. Puppet vs Chef package, file, service package { 'openssh-server': ensure

    => present, before => File['/etc/ssh/sshd_config'] } file { '/etc/ssh/sshd_config': ensure => file, mode => '0600', source => 'sshd_config' } service { 'sshd': ensure => running, enable => true, hasrestart => true, hasstatus => true, subscribe => File['/etc/ssh/sshd_config'] } package "openssh-server" do action :install end cookbook_file "/etc/ssh/sshd_config" do source "sshd_config" mode "0600" end service "sshd" do supports :status => true, :restart => true action [ :enable, :start ] subscribes :reload, resources( "cookbook_file[/etc/ssh/sshd_config]") end
  10. Resources Puppet & Chef: cron, exec/execute, file, group, mount, package,

    service, user Puppet: augeas, host, interface, nagios_command, ssh_authorized_key, sshkey, zfs, zone, … Chef: deploy, directory, env, git, HTTP request, Link, log, route, Ruby block, subversion, ...
  11. Puppet & Chef templates (ERB) # Puppet manifest: balancer.pp $nodes

    = [ "node100", "node101", "node102" ] file { '/etc/apache/balancer.conf': path => '/etc/apache/balancer.conf', ensure => file, content => template("balancer.erb") } # Chef recipe: balancer.rb template "/etc/apache/balancer.conf" do source "balancer.erb" variables({ :nodes => ["node100", "node101", "node102"] }) end
  12. Puppet & Chef templates (ERB) # Template: balancer.erb <Proxy balancer://mycluster>

    <% nodes.each do |node| -%> BalancerMember http://<%= node %>.cluster.xs:81 <% end -%> </Proxy> # Output: /etc/apache/balancer.conf <Proxy balancer://mycluster> BalancerMember http://node100.cluster.xs:81 BalancerMember http://node101.cluster.xs:81 BalancerMember http://node102.cluster.xs:81 </Proxy>
  13. Code reuse Puppet modules Manifests Files Libraries Templates (ERB) Chef

    cookbooks Recipes File Distribution Libraries Templates (ERB) Attributes Definitions Lightweight Resources & Providers (LWRP) Metadata
  14. Puppet Master / Agent Puppet Master Workstation Nodes Git Git

    MCollective PuppetDB Puppet Dashboard Puppet Agent Facter
  15. Chef Server / Client Chef API server Workstation Nodes Git

    knife Chef Indexer (Solr) Chef Web UI Chef Client Ohai CouchDB RabbitMQ knife (ssh)