SlideShare a Scribd company logo
Configuration Management
      with Puppet

  LinuxFest Northwest
       Garrett Honeycutt
        April 25th, 2010
What?




•   Puppet is open source and released under GPL

•   Backed by Puppet Labs - great training and audits available

•   Used by organizations such as Google, Marchex, Whitepages.com,
    Stanford University, Speakeasy, Harvard, Fedora, SANS Institute, etc..

•   “Puppet is a declarative language for expressing system configuration, a
    client and server for distributing it, and a library for realizing the
    configuration.” [1]
OS’s



• Linux (RHEL, CentOS, Debian, Ubuntu, Gentoo, SuSE, ...)
• BSD (Free, Open)
• Mac OS X
• Solaris (2.6 - 10)
• HP-UX
• AIX
• Windows scheduled for sometime in 2010
Packages

•   Source

•   Ruby Gems

•   Solaris - Blastwave

•   RPM - Fedora & EPEL

•   Debian / Ubuntu

•   SuSE

•   Gentoo

•   OpenBSD

•   OS X - MacPorts

•   ArchLinux

•   Mandriva
Why?




•   Configuration Management != SSH + for loops
Why?




•   Configuration Management != SSH + for loops

•   Abstraction layer lets you talk about WHAT not HOW

          package {“vim-enhanced”:
              ensure => installed,
          }
Why?




•   Configuration Management != SSH + for loops

•   Abstraction layer lets you talk about WHAT not HOW

           package {“vim-enhanced”:
               ensure => installed,
           }

•   Reduce entropy - why is mail27 so fragile?
Why?




•   Configuration Management != SSH + for loops

•   Abstraction layer lets you talk about WHAT not HOW

           package {“vim-enhanced”:
               ensure => installed,
           }

•   Reduce entropy - why is mail27 so fragile?

•   Ability to quickly scale number of machines
Why?




•   Configuration Management != SSH + for loops

•   Abstraction layer lets you talk about WHAT not HOW

           package {“vim-enhanced”:
               ensure => installed,
           }

•   Reduce entropy - why is mail27 so fragile?

•   Ability to quickly scale number of machines

•   Change management - How and when are system being modified?
Why?




•   No such thing as a One-Off
Why?




•   No such thing as a One-Off

    •   it’s only temporary - HA!
Why?




•   No such thing as a One-Off

    •   it’s only temporary - HA!

    •   create replicas in different environments (Dev, QA, Staging)
Why?




•   No such thing as a One-Off

    •   it’s only temporary - HA!

    •   create replicas in different environments (Dev, QA, Staging)

    •   disaster recovery
Client / Server




• Clients pulls a catalog from the puppetmaster
 • puppet.domain.tld
 • default is every 30 minutes
Server




• webrick by default
• best practice is Passenger
Diagram
Certs

 • Puppet communication is SSL encrypted XML-RPC
  • Supports auto signing - use with caution

[client]$ sudo puppetd --test

[puppetmaster]$ sudo puppetca --sign client.foo.com
What?




• Only need to describe parts of the system that you care about
 • So you can start in existing environments
 • not re-describe what a package already gets right
Idempotency




• Everything is built to be idempotent, even exec’s
 • no effect if the state is already achieved
 • safe to run multiple times
Repeatable State



• Start from a known base!
 • Cobbler
Repeatable State



• Start from a known base!
 • Cobbler
• Have a shared storage plan
 • Keep persistent data on the network
Repeatable State



• Start from a known base!
 • Cobbler
• Have a shared storage plan
 • Keep persistent data on the network
• Software package repository
 • Satellite / Spacewalk
 • Define processes for changing packages
services --enabled puppet             Kickstart

%packages
facter
puppet
ruby-rdoc

%post
# delete unneeded puppet cert
find /var/lib/puppet/ssl/ -type f |grep
localhost | xargs rm -f

# setup puppet cert
curl -k https://puppetca | tar xC /

# run puppet
/usr/sbin/puppetd -t
Written by Robert Long IV                                              gencert.php
<?php
  # don't assume we have a path
  $gencert = "/usr/sbin/puppetca -g";
  $tar     = "/bin/tar";
  $sudo    = "/usr/bin/sudo";

  # set some   paths up.
  $cabase =    "/var/lib/puppet/ssl/";
  $certdir =   "$cabase/certs";
  $private =   "$cabase/private_keys";

  # yeah, its reverse DNS, but don't assume its safe.
  $host    = escapeshellarg(gethostbyaddr($_SERVER['REMOTE_ADDR']));

  # create the certs
  exec("$sudo $gencert $host", $out, $ret);
  $ret && error_log("Error creating cert for $host: $outn");

  # tar up the three files we need to make the client work.
  exec("$sudo $tar -c $certdir/$host.pem $private/$host.pem $certdir/ca.pem 2>/dev/
null", $certs, $ret);
  $ret && error_log("Error tar'ing cert for $host: $certsn");

  # most of this is useless, but it will give curl an idea of what to expect in terms
of content
  header("Content-Description: File Transfer");
  header('Content-disposition: attachment; filename='.$host.'tar');
  header("Content-Type: application/octet-stream");
  header("Content-Transfer-Encoding: binary");

  # and the content goes here.
  print join("n", $certs);
?>
Facter
•   key => value system for retrieving information from your OS

architecture => x86_64
domain => garretthoneycutt.com
facterversion => 1.5.4
fqdn => blink.garretthoneycutt.com
hostname => blink
id => gh
ipaddress_eth0 => 172.17.2.38
kernel => Linux
kernelversion => 2.6.27.12
lsbdistcodename => Cambridge
lsbdistdescription => Fedora release 10 (Cambridge)
lsbdistrelease => 10
macaddress => 00:00:00:c0:ff:ee
memoryfree => 5.87 GB
memorysize => 7.80 GB
netmask => 255.255.255.128
network_eth0 => 172.17.2.0
operatingsystem => Fedora
operatingsystemrelease => 10
physicalprocessorcount => 1
processorcount => 2
rubyversion => 1.8.6
Facter

•   Written in Ruby




# some_fact.rb

Facter.add("some_fact") do
        setcode do
                %x{/usr/local/bin/stuff}.chomp
        end
end
You are a developer




• Speakeasy had 6000+ lines of code in the first year
• You need a VCS
 • and plan on how to use it
 • go talk to your Dev’s - they’ve probably figured
    this all out
Different environments




• Puppet allows for the notion of different
  environments
 • It’s a hack
• Run a different puppet server in each environment
 • Easy to run different puppetmasters off of
    different branches/tags of your code
File system layout

•   You want this in a VCS!
puppet
|_manifests
   |_ site.pp
       |_ sea0
       |_ wdc4
|_modules
   |_ apache
   |_ ...
   |_ zenoss
       |_ files
       |_ manifests
          |_ init.pp
       |_ templates
Site manifest
# Default file parameters
File {
    ignore => ".svn",
    owner => "root",
    group => "root",
    mode   => "644",
}

node default {
    include base
}

node ‘cobbler.foo.com’ inherits default {
    include cobbler
}
Types - brief list
•   cron

•   exec

•   file

•   group

•   host

•   mailalias

•   mount

•   nagios

•   package

•   service

•   sshkey

•   user

•   yumrepo
My first module - motd




class motd {
  file { “/etc/motd”:
    owner => “root”,
    group => “root”,
    mode   => 644,
    source => “puppet:///modules/motd/generic_motd”,
  }
}
Templates - motd

•   Uses ERB templating




class motd {
  file { “/etc/motd”:
    owner   => “root”,
    group   => “root”,
    mode    => 644,
    content => template(“motd/motd.erb”),
  }
}
motd.erb




Welcome to <%= fqdn %>
My uptime is <%= uptime %>
More advanced - resolv.conf.erb




search <%= dnssearchpath %>
options ndots:2 timeout:3
<% nameservers.each do |nameserver| -%>
nameserver <%= nameserver %>
<% end -%>
Ordering




• Puppet’s catalog is built using a DAG
• Has built in devices for ordering
 • before / require
 • subscribe / notify
Ordering - require




class vim {

    package { "vim-enhanced": ensure => installed, }

    file { "/etc/vimrc":
      source => "puppet:///modules/vim/vimrc-$operatingsystem",
      mode => "644",
      require => Package["vim-enhanced"],
    }
}
Ordering - notify

class bind {

    package { "bind”: ensure => installed, }

    file { "/etc/named.conf":
      content => template("bind/named.conf.erb"),
      mode    => "644",
      require => Package[“bind”],
      notify => Service["named"],
    }

    service { “named”:
      ensure => running,
      enable => true,
      require => [ Package[“bind”], File[“/etc/
      named.conf”] ],
    }
}
Inheritance - postfix

class postfix {
  package { “postfix”: ensure => present }

    file { “/etc/postfix/aliases”:
      require => Package[“postfix”],
      content => template(“postfix/aliases.erb”),
      notify => Exec[“postalias”],
    }

    service {   “postfix”:
      ensure    => running,
      enable    => true,
      require   => Package[“postfix”],
    }

    exec { “postalias”:
      command     => “/usr/sbin/postalias /etc/postfix/aliases”,
      require     => File[“/etc/postfix/aliases”],
      refreshonly => true,
    }
}
Inheritance - postfix

class postfix::perim inherits postfix {
  File { “/etc/postfix/aliases”:
    content => template(“postfix/perim-aliases.erb”),
  }

    file { “/etc/postfix/sender_regexp”:
      require => Package[“postfix”],
      notify => Service[“postfix”],
      content => template(“postfix/sender_regexp.erb”),
    }
}

class postfix::voicemail inherits postfix {
  File { “/etc/postfix/aliases”:
    content => template(“postfix/voicemail-aliases.erb”),
  }

    file { “/etc/postfix/network_table”:
      require => Package[“postfix”],
      notify => Service[“postfix”],
      source => “puppet:///postfix/voicemail-network_table”,
    }
}
defines
class postfix {
 ... all that stuff from before

    define post_files() {
      File {
        require => Package[“postfix”],
        notify => Service[“postfix”],
      }
      file {
        “/etc/postfix/master.cf”:
         source => “puppet:///postfix/$name/master.cf”;
        “/etc/postfix/main.cf”:
         source => “puppet:///postfix/$name/main.cf”;
      }
    }
}

class postfix::voicemail inherits postfix {
  post_files {“voicemail”: }
}
Scalability




•   use a load balancer for the puppetmasters

•   splay the time that your clients connect

•   dont run puppetd, instead call puppet from cron (puppetd -onetime)

•   recursive file serving is SLOW
Q &A
 Garrett Honeycutt
LinuxFest Northwest
   April 25th, 2010
References




•   http://projects.puppetlabs.com/projects/puppet/wiki/Big_Picture

•   Architecture diagram from slide 12 - http://reductivelabs.com/trac/puppet/
    wiki/ParsingArchitecture

More Related Content

What's hot (20)

PDF
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez
 
PDF
A tour of Ansible
DevOps Ltd.
 
KEY
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
PDF
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
Walter Heck
 
KEY
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
PDF
Configuration Surgery with Augeas
Puppet
 
PDF
Automating Complex Setups with Puppet
Kris Buytaert
 
PDF
Puppet fundamentals
Murali Boyapati
 
PDF
PuppetCamp SEA 1 - Puppet Deployment at OnApp
Walter Heck
 
PDF
Using cobbler in a not so small environment 1.77
chhorn
 
PPTX
Using puppet
Alex Su
 
PDF
Cassandra and docker
Ben Bromhead
 
PDF
PuppetCamp SEA 1 - Use of Puppet
Walter Heck
 
PDF
Getting started with Ansible
Ivan Serdyuk
 
PDF
Amazon EC2 Container Service in Action
Remotty
 
PDF
Docker Container Orchestration
Fernand Galiana
 
PDF
Cobbler, Func and Puppet: Tools for Large Scale Environments
ViSenze - Artificial Intelligence for the Visual Web
 
PDF
IT Automation with Ansible
Rayed Alrashed
 
PDF
Velocity 2011 Chef OpenStack Workshop
Chef Software, Inc.
 
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez
 
A tour of Ansible
DevOps Ltd.
 
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
Walter Heck
 
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
Configuration Surgery with Augeas
Puppet
 
Automating Complex Setups with Puppet
Kris Buytaert
 
Puppet fundamentals
Murali Boyapati
 
PuppetCamp SEA 1 - Puppet Deployment at OnApp
Walter Heck
 
Using cobbler in a not so small environment 1.77
chhorn
 
Using puppet
Alex Su
 
Cassandra and docker
Ben Bromhead
 
PuppetCamp SEA 1 - Use of Puppet
Walter Heck
 
Getting started with Ansible
Ivan Serdyuk
 
Amazon EC2 Container Service in Action
Remotty
 
Docker Container Orchestration
Fernand Galiana
 
Cobbler, Func and Puppet: Tools for Large Scale Environments
ViSenze - Artificial Intelligence for the Visual Web
 
IT Automation with Ansible
Rayed Alrashed
 
Velocity 2011 Chef OpenStack Workshop
Chef Software, Inc.
 

Viewers also liked (6)

PPTX
Social Media For HR Pros
SpringfieldEdge
 
PPTX
Ohio Construction Conference - David Zak - 3/8/2013
SpringfieldEdge
 
PPTX
Nextedge Overview
SpringfieldEdge
 
PPT
Tgs 2009 Mary Benedict (Odod)
SpringfieldEdge
 
PPT
SBA - Greater Springfield Chamber 12-3-2010
SpringfieldEdge
 
PDF
Greater ohio presentation
SpringfieldEdge
 
Social Media For HR Pros
SpringfieldEdge
 
Ohio Construction Conference - David Zak - 3/8/2013
SpringfieldEdge
 
Nextedge Overview
SpringfieldEdge
 
Tgs 2009 Mary Benedict (Odod)
SpringfieldEdge
 
SBA - Greater Springfield Chamber 12-3-2010
SpringfieldEdge
 
Greater ohio presentation
SpringfieldEdge
 
Ad

Similar to 20100425 Configuration Management With Puppet Lfnw (20)

PDF
20090514 Introducing Puppet To Sasag
garrett honeycutt
 
PPTX
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Miguel Zuniga
 
PPTX
Automating with Ansible
Ricardo Schmidt
 
PDF
Road to Opscon (Pisa '15) - DevOoops
Gianluca Varisco
 
PDF
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
PDF
From SaltStack to Puppet and beyond...
Yury Bushmelev
 
PDF
Lions, Tigers and Deers: What building zoos can teach us about securing micro...
Sysdig
 
PDF
Virtualization with Vagrant (ua.pycon 2011)
Dmitry Guyvoronsky
 
PDF
Deploying to Ubuntu on Linode
WO Community
 
PDF
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Codemotion
 
PDF
Cobbler, Func and Puppet: Tools for Large Scale Environments
Michael Zhang
 
PDF
WTF my container just spawned a shell!
Sysdig
 
PDF
Provisioning with Puppet
Joe Ray
 
PDF
Introduction to Ansible
Michael Bahr
 
PDF
EC2 AMI Factory with Chef, Berkshelf, and Packer
George Miranda
 
PDF
Ansible 101 - Presentation at Ansible STL Meetup
Jeff Geerling
 
PDF
Docking postgres
rycamor
 
PDF
From Dev to DevOps
Agile Spain
 
PPTX
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
PPT
Puppet
csrocks
 
20090514 Introducing Puppet To Sasag
garrett honeycutt
 
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Miguel Zuniga
 
Automating with Ansible
Ricardo Schmidt
 
Road to Opscon (Pisa '15) - DevOoops
Gianluca Varisco
 
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
From SaltStack to Puppet and beyond...
Yury Bushmelev
 
Lions, Tigers and Deers: What building zoos can teach us about securing micro...
Sysdig
 
Virtualization with Vagrant (ua.pycon 2011)
Dmitry Guyvoronsky
 
Deploying to Ubuntu on Linode
WO Community
 
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Codemotion
 
Cobbler, Func and Puppet: Tools for Large Scale Environments
Michael Zhang
 
WTF my container just spawned a shell!
Sysdig
 
Provisioning with Puppet
Joe Ray
 
Introduction to Ansible
Michael Bahr
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
George Miranda
 
Ansible 101 - Presentation at Ansible STL Meetup
Jeff Geerling
 
Docking postgres
rycamor
 
From Dev to DevOps
Agile Spain
 
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
Puppet
csrocks
 
Ad

More from garrett honeycutt (16)

PDF
20180823 - Sensu + Puppet
garrett honeycutt
 
PDF
Continuous Deployment Pipeline for Systems - Presented at Ohio LinuxFest 2017...
garrett honeycutt
 
PDF
Continuous Deployment Pipeline for Systems at Cascadia IT Conference - 2017-0...
garrett honeycutt
 
PDF
(2016-06-11) Packer: Make Multi-Platform Images
garrett honeycutt
 
PDF
20150613 self-puppet v4-avoiding_dragons
garrett honeycutt
 
PDF
20150314 - Functional Testing for Configuration Management @ Cascadia IT Con...
garrett honeycutt
 
PDF
2014-11-14 - Why Test Driven Development (TDD) Works for Sysadmins @ LISA14
garrett honeycutt
 
PDF
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
garrett honeycutt
 
PDF
2014-08-19 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Chicago
garrett honeycutt
 
PDF
20140406 loa days-tdd-with_puppet_tutorial
garrett honeycutt
 
PDF
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
garrett honeycutt
 
PDF
20130407 load puppevtv3-and_hiera
garrett honeycutt
 
KEY
20120331 - Expanded Intro to Puppet for LOAD
garrett honeycutt
 
PDF
20111110 how puppet-fits_into_your_existing_infrastructure_and_change_managem...
garrett honeycutt
 
PDF
20110611 expanded intro-to_puppet_for_self
garrett honeycutt
 
PDF
Fighting Spam With A Perimeter Mail System 20071108 Sasag
garrett honeycutt
 
20180823 - Sensu + Puppet
garrett honeycutt
 
Continuous Deployment Pipeline for Systems - Presented at Ohio LinuxFest 2017...
garrett honeycutt
 
Continuous Deployment Pipeline for Systems at Cascadia IT Conference - 2017-0...
garrett honeycutt
 
(2016-06-11) Packer: Make Multi-Platform Images
garrett honeycutt
 
20150613 self-puppet v4-avoiding_dragons
garrett honeycutt
 
20150314 - Functional Testing for Configuration Management @ Cascadia IT Con...
garrett honeycutt
 
2014-11-14 - Why Test Driven Development (TDD) Works for Sysadmins @ LISA14
garrett honeycutt
 
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
garrett honeycutt
 
2014-08-19 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Chicago
garrett honeycutt
 
20140406 loa days-tdd-with_puppet_tutorial
garrett honeycutt
 
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
garrett honeycutt
 
20130407 load puppevtv3-and_hiera
garrett honeycutt
 
20120331 - Expanded Intro to Puppet for LOAD
garrett honeycutt
 
20111110 how puppet-fits_into_your_existing_infrastructure_and_change_managem...
garrett honeycutt
 
20110611 expanded intro-to_puppet_for_self
garrett honeycutt
 
Fighting Spam With A Perimeter Mail System 20071108 Sasag
garrett honeycutt
 

20100425 Configuration Management With Puppet Lfnw

  • 1. Configuration Management with Puppet LinuxFest Northwest Garrett Honeycutt April 25th, 2010
  • 2. What? • Puppet is open source and released under GPL • Backed by Puppet Labs - great training and audits available • Used by organizations such as Google, Marchex, Whitepages.com, Stanford University, Speakeasy, Harvard, Fedora, SANS Institute, etc.. • “Puppet is a declarative language for expressing system configuration, a client and server for distributing it, and a library for realizing the configuration.” [1]
  • 3. OS’s • Linux (RHEL, CentOS, Debian, Ubuntu, Gentoo, SuSE, ...) • BSD (Free, Open) • Mac OS X • Solaris (2.6 - 10) • HP-UX • AIX • Windows scheduled for sometime in 2010
  • 4. Packages • Source • Ruby Gems • Solaris - Blastwave • RPM - Fedora & EPEL • Debian / Ubuntu • SuSE • Gentoo • OpenBSD • OS X - MacPorts • ArchLinux • Mandriva
  • 5. Why? • Configuration Management != SSH + for loops
  • 6. Why? • Configuration Management != SSH + for loops • Abstraction layer lets you talk about WHAT not HOW package {“vim-enhanced”: ensure => installed, }
  • 7. Why? • Configuration Management != SSH + for loops • Abstraction layer lets you talk about WHAT not HOW package {“vim-enhanced”: ensure => installed, } • Reduce entropy - why is mail27 so fragile?
  • 8. Why? • Configuration Management != SSH + for loops • Abstraction layer lets you talk about WHAT not HOW package {“vim-enhanced”: ensure => installed, } • Reduce entropy - why is mail27 so fragile? • Ability to quickly scale number of machines
  • 9. Why? • Configuration Management != SSH + for loops • Abstraction layer lets you talk about WHAT not HOW package {“vim-enhanced”: ensure => installed, } • Reduce entropy - why is mail27 so fragile? • Ability to quickly scale number of machines • Change management - How and when are system being modified?
  • 10. Why? • No such thing as a One-Off
  • 11. Why? • No such thing as a One-Off • it’s only temporary - HA!
  • 12. Why? • No such thing as a One-Off • it’s only temporary - HA! • create replicas in different environments (Dev, QA, Staging)
  • 13. Why? • No such thing as a One-Off • it’s only temporary - HA! • create replicas in different environments (Dev, QA, Staging) • disaster recovery
  • 14. Client / Server • Clients pulls a catalog from the puppetmaster • puppet.domain.tld • default is every 30 minutes
  • 15. Server • webrick by default • best practice is Passenger
  • 17. Certs • Puppet communication is SSL encrypted XML-RPC • Supports auto signing - use with caution [client]$ sudo puppetd --test [puppetmaster]$ sudo puppetca --sign client.foo.com
  • 18. What? • Only need to describe parts of the system that you care about • So you can start in existing environments • not re-describe what a package already gets right
  • 19. Idempotency • Everything is built to be idempotent, even exec’s • no effect if the state is already achieved • safe to run multiple times
  • 20. Repeatable State • Start from a known base! • Cobbler
  • 21. Repeatable State • Start from a known base! • Cobbler • Have a shared storage plan • Keep persistent data on the network
  • 22. Repeatable State • Start from a known base! • Cobbler • Have a shared storage plan • Keep persistent data on the network • Software package repository • Satellite / Spacewalk • Define processes for changing packages
  • 23. services --enabled puppet Kickstart %packages facter puppet ruby-rdoc %post # delete unneeded puppet cert find /var/lib/puppet/ssl/ -type f |grep localhost | xargs rm -f # setup puppet cert curl -k https://puppetca | tar xC / # run puppet /usr/sbin/puppetd -t
  • 24. Written by Robert Long IV gencert.php <?php # don't assume we have a path $gencert = "/usr/sbin/puppetca -g"; $tar = "/bin/tar"; $sudo = "/usr/bin/sudo"; # set some paths up. $cabase = "/var/lib/puppet/ssl/"; $certdir = "$cabase/certs"; $private = "$cabase/private_keys"; # yeah, its reverse DNS, but don't assume its safe. $host = escapeshellarg(gethostbyaddr($_SERVER['REMOTE_ADDR'])); # create the certs exec("$sudo $gencert $host", $out, $ret); $ret && error_log("Error creating cert for $host: $outn"); # tar up the three files we need to make the client work. exec("$sudo $tar -c $certdir/$host.pem $private/$host.pem $certdir/ca.pem 2>/dev/ null", $certs, $ret); $ret && error_log("Error tar'ing cert for $host: $certsn"); # most of this is useless, but it will give curl an idea of what to expect in terms of content header("Content-Description: File Transfer"); header('Content-disposition: attachment; filename='.$host.'tar'); header("Content-Type: application/octet-stream"); header("Content-Transfer-Encoding: binary"); # and the content goes here. print join("n", $certs); ?>
  • 25. Facter • key => value system for retrieving information from your OS architecture => x86_64 domain => garretthoneycutt.com facterversion => 1.5.4 fqdn => blink.garretthoneycutt.com hostname => blink id => gh ipaddress_eth0 => 172.17.2.38 kernel => Linux kernelversion => 2.6.27.12 lsbdistcodename => Cambridge lsbdistdescription => Fedora release 10 (Cambridge) lsbdistrelease => 10 macaddress => 00:00:00:c0:ff:ee memoryfree => 5.87 GB memorysize => 7.80 GB netmask => 255.255.255.128 network_eth0 => 172.17.2.0 operatingsystem => Fedora operatingsystemrelease => 10 physicalprocessorcount => 1 processorcount => 2 rubyversion => 1.8.6
  • 26. Facter • Written in Ruby # some_fact.rb Facter.add("some_fact") do setcode do %x{/usr/local/bin/stuff}.chomp end end
  • 27. You are a developer • Speakeasy had 6000+ lines of code in the first year • You need a VCS • and plan on how to use it • go talk to your Dev’s - they’ve probably figured this all out
  • 28. Different environments • Puppet allows for the notion of different environments • It’s a hack • Run a different puppet server in each environment • Easy to run different puppetmasters off of different branches/tags of your code
  • 29. File system layout • You want this in a VCS! puppet |_manifests |_ site.pp |_ sea0 |_ wdc4 |_modules |_ apache |_ ... |_ zenoss |_ files |_ manifests |_ init.pp |_ templates
  • 30. Site manifest # Default file parameters File { ignore => ".svn", owner => "root", group => "root", mode => "644", } node default { include base } node ‘cobbler.foo.com’ inherits default { include cobbler }
  • 31. Types - brief list • cron • exec • file • group • host • mailalias • mount • nagios • package • service • sshkey • user • yumrepo
  • 32. My first module - motd class motd { file { “/etc/motd”: owner => “root”, group => “root”, mode => 644, source => “puppet:///modules/motd/generic_motd”, } }
  • 33. Templates - motd • Uses ERB templating class motd { file { “/etc/motd”: owner => “root”, group => “root”, mode => 644, content => template(“motd/motd.erb”), } }
  • 34. motd.erb Welcome to <%= fqdn %> My uptime is <%= uptime %>
  • 35. More advanced - resolv.conf.erb search <%= dnssearchpath %> options ndots:2 timeout:3 <% nameservers.each do |nameserver| -%> nameserver <%= nameserver %> <% end -%>
  • 36. Ordering • Puppet’s catalog is built using a DAG • Has built in devices for ordering • before / require • subscribe / notify
  • 37. Ordering - require class vim { package { "vim-enhanced": ensure => installed, } file { "/etc/vimrc": source => "puppet:///modules/vim/vimrc-$operatingsystem", mode => "644", require => Package["vim-enhanced"], } }
  • 38. Ordering - notify class bind { package { "bind”: ensure => installed, } file { "/etc/named.conf": content => template("bind/named.conf.erb"), mode => "644", require => Package[“bind”], notify => Service["named"], } service { “named”: ensure => running, enable => true, require => [ Package[“bind”], File[“/etc/ named.conf”] ], } }
  • 39. Inheritance - postfix class postfix { package { “postfix”: ensure => present } file { “/etc/postfix/aliases”: require => Package[“postfix”], content => template(“postfix/aliases.erb”), notify => Exec[“postalias”], } service { “postfix”: ensure => running, enable => true, require => Package[“postfix”], } exec { “postalias”: command => “/usr/sbin/postalias /etc/postfix/aliases”, require => File[“/etc/postfix/aliases”], refreshonly => true, } }
  • 40. Inheritance - postfix class postfix::perim inherits postfix { File { “/etc/postfix/aliases”: content => template(“postfix/perim-aliases.erb”), } file { “/etc/postfix/sender_regexp”: require => Package[“postfix”], notify => Service[“postfix”], content => template(“postfix/sender_regexp.erb”), } } class postfix::voicemail inherits postfix { File { “/etc/postfix/aliases”: content => template(“postfix/voicemail-aliases.erb”), } file { “/etc/postfix/network_table”: require => Package[“postfix”], notify => Service[“postfix”], source => “puppet:///postfix/voicemail-network_table”, } }
  • 41. defines class postfix { ... all that stuff from before define post_files() { File { require => Package[“postfix”], notify => Service[“postfix”], } file { “/etc/postfix/master.cf”: source => “puppet:///postfix/$name/master.cf”; “/etc/postfix/main.cf”: source => “puppet:///postfix/$name/main.cf”; } } } class postfix::voicemail inherits postfix { post_files {“voicemail”: } }
  • 42. Scalability • use a load balancer for the puppetmasters • splay the time that your clients connect • dont run puppetd, instead call puppet from cron (puppetd -onetime) • recursive file serving is SLOW
  • 43. Q &A Garrett Honeycutt LinuxFest Northwest April 25th, 2010
  • 44. References • http://projects.puppetlabs.com/projects/puppet/wiki/Big_Picture • Architecture diagram from slide 12 - http://reductivelabs.com/trac/puppet/ wiki/ParsingArchitecture