puppet - automagically manage your configuration

69
Puppet Automagically Manage Your Configuration 12/04/2010 Carla Souza DevOps 2010 Brazil © Carla Souza

Upload: carlaasouza

Post on 11-May-2015

2.709 views

Category:

Technology


2 download

DESCRIPTION

Puppet's presentation at DevOps Days Brasil Dec 2010 @ São Paulo - SP

TRANSCRIPT

Page 1: Puppet - Automagically Manage your Configuration

Puppet

Automagically Manage YourConfiguration

12/04/2010

Carla Souza

DevOps 2010 Brazil © Carla Souza

Page 2: Puppet - Automagically Manage your Configuration

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 3: Puppet - Automagically Manage your Configuration

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 4: Puppet - Automagically Manage your Configuration

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 5: Puppet - Automagically Manage your Configuration

Typical Sysadmin Job

• Repetitive

• Manual

• Tedious

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 6: Puppet - Automagically Manage your Configuration

Typical Sysadmin Job

Installation

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 7: Puppet - Automagically Manage your Configuration

Typical Sysadmin Job

Installation

Configuration

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 8: Puppet - Automagically Manage your Configuration

Typical Sysadmin Job

Installation

Configuration

UpdatesFixes

Audits

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 9: Puppet - Automagically Manage your Configuration

Typical Sysadmin Job

Installation

Configuration

UpdatesFixes

Audits

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 10: Puppet - Automagically Manage your Configuration

After Configuration...

• What was it configured?– How?– Why?

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 11: Puppet - Automagically Manage your Configuration

After Configuration...

• What was it configured?– How?– Why?

• We need Documentation!

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 12: Puppet - Automagically Manage your Configuration

Documentation

• When was it configured?• Who configured it?• What were the configuration's

objectives?

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 13: Puppet - Automagically Manage your Configuration

Documentation

• When was it configured?• Who configured it?• What were the configuration's

objectives?• Be consistent

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 14: Puppet - Automagically Manage your Configuration

After configuration...

• Is it well configured?

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 15: Puppet - Automagically Manage your Configuration

After configuration...

• Is it well configured?– Bad configuration is worse than no

configuration

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 16: Puppet - Automagically Manage your Configuration

After configuration...

• Is it well configured?– Bad configuration is worse then no

configuration– We make mistakes!

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 17: Puppet - Automagically Manage your Configuration

After configuration...

• Is it well configured?– Bad configuration is worse then no

configuration– We make mistakes!

• We need Tests!

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 18: Puppet - Automagically Manage your Configuration

Tests

• Is the configuration correct?• Is it correctly configured?

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 19: Puppet - Automagically Manage your Configuration

After Configuration...

• How to ensure that it will stay configured correctly over time?

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 20: Puppet - Automagically Manage your Configuration

After Configuration...

• How to ensure that it will stay configured correctly over time?

• We need Maintenance!

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 21: Puppet - Automagically Manage your Configuration

Maintenance

• Repetitive work– Every time you repeat one job, you waste

time

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 22: Puppet - Automagically Manage your Configuration

Maintenance

• Repetitive work– Every time you repeat one job, you waste

time MONEY

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 23: Puppet - Automagically Manage your Configuration

Documentation + Tests + Maintenance

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 24: Puppet - Automagically Manage your Configuration

Documentation + Tests + Maintenance

Spend more time then you think

=

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 25: Puppet - Automagically Manage your Configuration

Documentation + Tests + Maintenance

Spend more time then you think

Less time for real important work

=

=

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 26: Puppet - Automagically Manage your Configuration

The more applications I have

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 27: Puppet - Automagically Manage your Configuration

The more applications I have

More Risks=

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 28: Puppet - Automagically Manage your Configuration

The more applications I have

More Risks=

+More need for documentation

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 29: Puppet - Automagically Manage your Configuration

Cumulative Effect

• The time left will be only for fire fighting

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 30: Puppet - Automagically Manage your Configuration

Cumulative Effect

• The time left will be only for fire fighting

• Important tasks will be left behind

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 31: Puppet - Automagically Manage your Configuration

Cumulative Effect

• The time left will be only for fire fighting

• Important tasks will be left behind– Backups– Documentation update– User’s tickets

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 32: Puppet - Automagically Manage your Configuration

Automation

• Good admins write their own tools

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 33: Puppet - Automagically Manage your Configuration

Automation

• Good admins write their own tools• Install:

– Kickstart, jumpstart, imaging• Configuration + maintenance:

– SSH in a for loop• Ssh keys distributed over the network = lack of

secutiry

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 34: Puppet - Automagically Manage your Configuration

Automation tools

• Great for ad-hoc or one time only tasks• Can be pushed out via cron

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 35: Puppet - Automagically Manage your Configuration

Automation tools

• But do you always write scripts that are:

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 36: Puppet - Automagically Manage your Configuration

Automation tools

• But do you always write scripts that are:– Concurrent safe?– Testable?– Reversible?– Legible?– Full of good logging?– Portable?

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 37: Puppet - Automagically Manage your Configuration

Wish list

• Simple solutions

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 38: Puppet - Automagically Manage your Configuration

Wish list

• Simple solutions– Elegant Domain Specific Language (DSL)

• Manage your servers by writing code, not running commands

– Platform independent– Centralized– Version Controlled

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 39: Puppet - Automagically Manage your Configuration

Wish list

• Simple solutions– Easy to extend– Self documenting– Commercial support and trainning– Open source

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 40: Puppet - Automagically Manage your Configuration

Puppet

• A Puppet Labs product• Since 2005• Written in Ruby• Extensible by modules• Client-server architecture (client pull)

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 41: Puppet - Automagically Manage your Configuration

Puppet

• File server• SSL Certificates• Very active and helpful community

– Mailing lists, #puppet @ freenode• Open Source hosted on Github (GPL)

– https://github.com/puppetlabs• Book

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 42: Puppet - Automagically Manage your Configuration

Puppet

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 43: Puppet - Automagically Manage your Configuration

Puppet

Installation

Configuration

UpdatesFixes

Audits

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 44: Puppet - Automagically Manage your Configuration

Components

• puppetmaster– Server daemon– Run as ‘puppet’ user

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 45: Puppet - Automagically Manage your Configuration

Components

• puppetmaster– Server daemon– Run as ‘puppet’ user

• puppetd– Client daemon– Run as root– Pulling every 30min (default value)

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 46: Puppet - Automagically Manage your Configuration

Components

• puppetca– Puppet’s Certificate Authority

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 47: Puppet - Automagically Manage your Configuration

Components

• puppetca– Puppet’s Certificate Authority

• Facter– Gathers basic information about node’s

hardware and operation system

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 48: Puppet - Automagically Manage your Configuration

Elements

• Types– A type is a particular element that Puppet

knows how to configure

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 49: Puppet - Automagically Manage your Configuration

Elements

• Types– A type is a particular element that Puppet

knows how to configure

• Classes– A named collection of type objects

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 50: Puppet - Automagically Manage your Configuration

Elements

• Providers– Specific implementation of a given

resource type

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 51: Puppet - Automagically Manage your Configuration

Elements

• Providers– Specific implementation of a given

resource type

type: package

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 52: Puppet - Automagically Manage your Configuration

Elements

• Providers– Specific implementation of a given

resource type

type: packageproviders: yum, dpkg, aptitude, apple, rpm, gem, freebsd

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 53: Puppet - Automagically Manage your Configuration

Puppet’s installation

• yum install puppet-server puppet

• apt-get install puppetmaster puppet

• gem install puppet-2.6.4.gem

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 54: Puppet - Automagically Manage your Configuration

Sample CodeInstall, Configure and Start Apache

12/04/2010 DevOps 2010 Brazil © Carla Souza

package {“httpd”:ensure => present,

}file {“/etc/httpd/conf/httpd.conf”:

owner => root, group => root, mode => 644,source => puppet:///modules/apache/httpd.conf,

}service {“httpd”:

ensure => running,enable => true,

}

Page 55: Puppet - Automagically Manage your Configuration

Sample CodeResource Types

12/04/2010 DevOps 2010 Brazil © Carla Souza

package {“httpd”:ensure => present,

}file {“/etc/httpd/conf/httpd.conf”:

owner => root, group => root, mode => 644,source => puppet:///modules/apache/httpd.conf,

}service {“httpd”:

ensure => running,enable => true,

}

Page 56: Puppet - Automagically Manage your Configuration

Sample CodeResource Titles

12/04/2010 DevOps 2010 Brazil © Carla Souza

package {“httpd”:ensure => present,

}file {“/etc/httpd/conf/httpd.conf”:

owner => root, group => root, mode => 644,source => puppet:///modules/apache/httpd.conf,

}service {“httpd”:

ensure => running,enable => true,

}

Page 57: Puppet - Automagically Manage your Configuration

Sample CodeResources Parameters

12/04/2010 DevOps 2010 Brazil © Carla Souza

package {“httpd”:ensure => present,

}file {“/etc/httpd/conf/httpd.conf”:

owner => root, group => root, mode => 644,source => puppet:///modules/apache/httpd.conf,

}service {“httpd”:

ensure => running,enable => true,

}

Page 58: Puppet - Automagically Manage your Configuration

Sample CodeResources Parameters

12/04/2010 DevOps 2010 Brazil © Carla Souza

package {“httpd”:ensure => present,

}file {“/etc/httpd/conf/httpd.conf”:

owner => root, group => root, mode => 644,source => puppet:///modules/apache/httpd.conf,require => Package[“httpd”]

}service {“httpd”:

ensure => running,enable => true,require => File[“/etc/httpd/conf/httpd.conf”]

}

Page 59: Puppet - Automagically Manage your Configuration

Sample CodeResponding to change

12/04/2010 DevOps 2010 Brazil © Carla Souza

file{“/etc/httpd/conf/httpd.conf”:..notify => Service[“httpd”]

}ORservice{“httpd”:

.

.subscribe => File[“/etc/httpd/conf/httpd.conf”]

}

Page 60: Puppet - Automagically Manage your Configuration

Sample CodeResource collections

class apache {include apache::installinclude apache::configinclude apache::service

}class apache::install {

package{.....}, package{.....}}class apache::config {

file{.....require => Class[“apache::install”],notify => Class[“apache::service”],

}}class apache::service {

service{.....require => Class[“apache::config”]

}} 12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 61: Puppet - Automagically Manage your Configuration

Sample CodeResource collections

class apache {include apache::installinclude apache::configinclude apache::service

}class apache::install {

package{.....}, package{.....}}class apache::config {

file{.....require => Class[“apache::install”],notify => Class[“apache::service”],

}}class apache::service {

service{.....require => Class[“apache::config”]

}} 12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 62: Puppet - Automagically Manage your Configuration

Sample CodeResource collections

class apache {include apache::installinclude apache::configinclude apache::service

}class apache::install {

package{.....}, package{.....}}class apache::config {

file{.....require => Class[“apache::install”],notify => Class[“apache::service”],

}}class apache::service {

service{.....require => Class[“apache::config”]

}} 12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 63: Puppet - Automagically Manage your Configuration

Elements

• Nodes– A configuration block matching a client

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 64: Puppet - Automagically Manage your Configuration

Sample CodeNodes configuration

node “web1.your.com” {include apache

}

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 65: Puppet - Automagically Manage your Configuration

Elements

• Templates– Apply code and variable substitution– Uses ERB

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 66: Puppet - Automagically Manage your Configuration

Sample CodeTemplates

file{“/etc/httpd/conf.d/servertag.conf”:..content => template(“apache/servertag.erb”)

}

servertag.erb:

Header set X-httpd <%= hostname %>

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 67: Puppet - Automagically Manage your Configuration

Sample CodeFile Source Selection

file{“/etc/httpd/conf/httpd.conf”:source => [“puppet:///apache/httpd.conf.${fqdn}”,

“puppet:///apache/httpd.conf.${domain}”, “puppet:///apache/httpd.conf”]

}

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 68: Puppet - Automagically Manage your Configuration

Puppet

• puppetlabs.com– github.com/puppetlabs

• Follow me:– github.com/carlasouza– [email protected]

12/04/2010 DevOps 2010 Brazil © Carla Souza

Page 69: Puppet - Automagically Manage your Configuration

Thank you!

12/04/2010 DevOps 2010 Brazil © Carla Souza