puppet talk

Upload: d2605238

Post on 07-Apr-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Puppet Talk

    1/24

    Managing Systems with Puppet

    Eric Eisenhart

    SoCoSAAugust 7, 2007

    mailto:[email protected]:[email protected]
  • 8/6/2019 Puppet Talk

    2/24

    Overview

    Overview

    Who's Eric?

    What Is Puppet?

    Comparisons

    Client, Server, and Protocol

    Language

    More Language...

    Some more Language...

    Real Examples

    Q&A

  • 8/6/2019 Puppet Talk

    3/24

    08/16/07 Eric's August SoCoSA puppet talk 3

    Who's Eric?Why does he want to automate?

    Unix user for 15 years

    Unix sysadmin for 12 years

    Currently: Lead Unix sysadmin at SSU

    ~80 *nix servers ~half highly customer visible (announce outages, etc.)

    Mostly RHEL; a little RHL (gone soon), a few Solaris

    1.5 admins (other unix admin is also storage admin)

    Recent purchases: about a dozen more servers Expected this FY: another 9 for sure

    plus another dozen or so likely?

    plus more test systems?

  • 8/6/2019 Puppet Talk

    4/2408/16/07 Eric's August SoCoSA puppet talk 4

    What Is Puppet?

    A declarative language for expressing systemconfiguration

    a client & server for distributing it

    a library for realizing the configuration an open development community

    With a 2-person company behind it

  • 8/6/2019 Puppet Talk

    5/2408/16/07 Eric's August SoCoSA puppet talk 5

    Huh? What's that mean?

    A way to manage many computers withouttouching them

    Make the computers do the boring work and

    concentrate on interesting things

  • 8/6/2019 Puppet Talk

    6/2408/16/07 Eric's August SoCoSA puppet talk 6

    Comparable Solutions cfengine

    Bcfg2

    lcfg

    radmind

    Opsware

    BladeLogic

    Microsoft SMS

    Netdirector

    IBM Tivoli

  • 8/6/2019 Puppet Talk

    7/2408/16/07 Eric's August SoCoSA puppet talk 7

    Incomparable Solutions

    shell script loops

    for host in `cat rhel4boxes`; dossh root@$host \perl -pie 's/foo/bar/' /etc/baz

    done

    Installation-time scripting (kickstart)

    Crazy RPM tricks

    %postperl -pie 's/foo/bar/' /etc/baz

    Disk imaging (dd, ghost, etc.)

  • 8/6/2019 Puppet Talk

    8/2408/16/07 Eric's August SoCoSA puppet talk 8

    Client, Server, and Protocol

    Protocol: SSL; CA builtin

    Server: listens on one master

    Client: daemon runs on many nodes and wakes

    up every 30 minutes factsync, pluginsync, reports

  • 8/6/2019 Puppet Talk

    9/2408/16/07 Eric's August SoCoSA puppet talk 9

    Client Server

    Client wakes up

    Client connects to server

    Client sends facts to server

    Server compiles configuration

    Server sends configuration

    Client loads configuration

    Client runs needed transactions

    (Optional) Client fetches more stuff from server

    Client sends report to server

  • 8/6/2019 Puppet Talk

    10/2408/16/07 Eric's August SoCoSA puppet talk 10

    Client

    Transactional

    Idempotent

    Modular

    Resource Types Resource Providers

    Reusable

  • 8/6/2019 Puppet Talk

    11/2408/16/07 Eric's August SoCoSA puppet talk 11

    Library

    Ruby

    Reusable

    Swappable

    Extensible

    new types can be just one ruby file

    plugins!

  • 8/6/2019 Puppet Talk

    12/2408/16/07 Eric's August SoCoSA puppet talk 12

    Language: structure

    nodes

    inheritance

    classes

    types

    definitions

    Lions, Tigers and Bears!

  • 8/6/2019 Puppet Talk

    13/24

    08/16/07 Eric's August SoCoSA puppet talk 13

    Language: Types

    Any Unix:

    cron, exec, file, group, host, mount, package,service, sshkey, tidy, user

    Exclusive: yumrepo, zone

    Special:

    schedule, filebucket

  • 8/6/2019 Puppet Talk

    14/24

    08/16/07 Eric's August SoCoSA puppet talk 14

    Metaparameters

    name

    alias

    before & require

    notify & subscribe schedule

    tag

  • 8/6/2019 Puppet Talk

    15/24

    08/16/07 Eric's August SoCoSA puppet talk 15

    Type examples

    cron { logrotate:command => /usr/sbin/logrotate,user => root,hour => 2,

    minute => 0,}

    package { kernel: ensure => latest }

    host { foo.org: ip => 10.2.5.2 } user { eric: ensure => present }

  • 8/6/2019 Puppet Talk

    16/24

    08/16/07 Eric's August SoCoSA puppet talk 16

    Type examples: exec

    exec { make stuff:cwd => /nfs/example/foo,creates => /nfs/example/foo/stuff,require => Mount[/nfs/example/foo],

    } command, creates, cwd, env, group, logoutput,

    onlyif, path, refresh, refreshonly, returns,timeout, unless, user

  • 8/6/2019 Puppet Talk

    17/24

    08/16/07 Eric's August SoCoSA puppet talk 17

    Conditionals

    file { "/some/file":owner => $os ? {

    sunos => "adm",redhat => "bin",

    },mode => 0755, owner => root,

    }

    case $operatingsystem {

    sunos: { include solaris }redhat: { include redhat }default: { include generic }

    }

  • 8/6/2019 Puppet Talk

    18/24

    08/16/07 Eric's August SoCoSA puppet talk 18

    Definitions

    define apache::virtual_host($docroot, $ip, $order =500, $ensure = "enabled") {

    $file = "/etc/sites-available/$name.conf"# The template fills in the docroot, ip, and

    name.

    file { $file:content => template("virtual_host.erb"),notify => Service[apache]

    }file { "/etc/sites-enabled/$order-$name.conf":ensure => $ensure ? {enabled => $file,disabled => absent

    }}

    }

  • 8/6/2019 Puppet Talk

    19/24

    08/16/07 Eric's August SoCoSA puppet talk 19

    Language: classes

    class ntp {file { "/etc/ntp.conf":source => [

    "puppet://$puppetserver/ntp/ntp.conf.$hostname","puppet://$puppetserver/ntp/ntp.conf"

    ],notify => Service[ntpd],

    }

    service { "ntpd":ensure => running,enable => true,

    }

    package { ntp-server: ensure => installed }}

  • 8/6/2019 Puppet Talk

    20/24

    08/16/07 Eric's August SoCoSA puppet talk 20

    Templates(ERB)

    $backupserver = [ foo, bar ]$backupclient = baz;file { "/opt/openv/.../bp.conf":content => template("nbp/bp_conf.erb")

    } # HEADER: Do not edit on live system.# HEADER: Look in puppet instead.

    SERVER = CLIENT_NAME =

    See also: generate()

  • 8/6/2019 Puppet Talk

    21/24

    08/16/07 Eric's August SoCoSA puppet talk 21

    Modules

    # cd /etc/puppet/modules/netbackup_client# find . | grep -v CVS../templates

    ./templates/bp_conf.erb./README

    ./manifests

    ./manifests/init.pp

    ./files

    ./files/NET_BUFFER_SZ

  • 8/6/2019 Puppet Talk

    22/24

    08/16/07 Eric's August SoCoSA puppet talk 22

    Bringing it all together

    node obsidian inherits typicalserver {include apachevirtualhost { www.example.org:

    ip => 10.2.5.7,docroot => /var/www/example.org/htdocs,

    }

    }

    node default inherits typicalserver {}

    node typicalserver {include $operatingsystem

    include securityinclude ntpinclude ssh

    }

  • 8/6/2019 Puppet Talk

    23/24

    08/16/07 Eric's August SoCoSA puppet talk 23

    Show and Tell

  • 8/6/2019 Puppet Talk

    24/24

    08/16/07 Eric's August SoCoSA puppet talk 24

    Q&A