SlideShare a Scribd company logo
Puppet: What
_not_ to do?
 An interactive journey through the ugly side
of Puppet
•Walter Heck, Founder of OlinData
•2,5 years experience with Puppet in 5+
different environments

•Experienced Puppet Fundamentals trainer
•Had my eyes bleed many times with ugly
Puppet code
•    Design mistakes
    might not be glaringly obvious or even
    wrong at first, but will cause trouble later

•    Language mistakes
    Puppet provides functionality that
    shouldn't be used, but is there for edge-
    cases or historical purposes
Quiz time!
  Wake up...
== File: modules/ssh/manifests/ssh.pp

class ssh_install {
 package { 'ssh':
   ensure => present
 }
}

class ssh_configure {
 file { '/etc/ssh/sshd_config':
   ensure => present
 }
}
== File: modules/ssh/manifests/ssh.pp

class ssh($state = ‘present’ {
 package { 'ssh':
   ensure => $state
 }

 file { '/etc/ssh/sshd_config':
   ensure => $state
 }
}
# problem: classnames won't be autoloaded, classnames shouldn't have verbs in them,
classes should be combined, don't put multiple classes in a file
==

schedule {   'maint':
 range =>    '2 - 4',
 period =>   daily,
 repeat =>   1,
}

exec { '/usr/bin/apt-get update':
 schedule => 'maint',
}
==

schedule {         'maint':
 range =>          '2 - 4',
 period =>         daily,
 repeat =>         1,
}
exec { '/usr/bin/apt-get update':
 schedule => 'maint',
}
# problem: schedule doesn't mean something will execute, a common pitfall.
If there is no puppet run between these hours, the apt-get exec will not be run
==
$myvar = ‘false’

if ($myvar) {
  notice(‘this is true’)
} else {
  notice(‘This is false’)
}
==
$myvar = ‘false’

if ($myvar) {
  notice(‘this is true’)
} else {
  notice(‘This is false’)
}
#problem: 'false' evaluates to
true
==

exec { '/etc/init.d/apache start':
 onlyif => ‘ps aux | grep apache | grep -v grep |
wc -l’
}
==

exec { '/etc/init.d/apache start':
 onlyif => ‘ps aux | grep apache | grep -v grep |
wc -l’
}

# problem: this shouldn't be an exec, but a
service
==

package { 'ssh':
 ensure => present,
 name   => $::operatingsystem ? {
   'Ubuntu' => 'openssh-server',
   default => 'ssh',
 },
}
==
$sshpkgname = $::operatingsystem ? {
  'Ubuntu' => 'openssh-server',
  default => undef,
}

if ($sshpkgname == undef) {
  fail(‘unsupported OS’)
} else {
  package { 'ssh':
    ensure => present,
    name   => $sshpkgname,
  }
}

#problem: they encourage behaviour that is not scalable, using default options to
assume things, etc.
==
case $::operatingsystem {
 'RedHat', 'CentOS': {
   file { ‘/etc/httpd/http.conf’:
     ensure => ‘present’,
   }
 }
 default: {
   file { ‘/etc/apache2/apache2.conf’:
     ensure => ‘present’,
   }
 }
}
==
case $::operatingsystem {
  'RedHat', 'CentOS': {
    file { ‘/etc/httpd/http.conf’:
      ensure => ‘present’,
    }
  }
  default: {
    file { ‘/etc/apache2/apache2.conf’:
      ensure => ‘present’,
    }
  }
}
#problem: case without default that fails, instead it assumes
==
class wordpress {

    $wordpress_archive = 'wordpress-3.4.1.zip'

    $apache = $::operatingsystem ? {
      Ubuntu   => apache2,
      CentOS   => httpd,
      Debian   => apache2,
      default => httpd
    }

    $phpmysql = $::operatingsystem ? {
      Ubuntu   => php5-mysql,
      CentOS   => php-mysql,
      Debian   => php5-mysql,
      default => php-mysql
    }

    $php = $::operatingsystem ? {
      Ubuntu   => libapache2-mod-php5,
      CentOS   => php,
      Debian   => libapache2-mod-php5,
      default => php
    }

    package { ['unzip',$apache,$php,$phpmysql]:
      ensure => latest
    }
}
==
class wordpress {

    $wordpress_archive = 'wordpress-3.4.1.zip'

    $apache = $::operatingsystem ? {
      Ubuntu   => apache2,
      CentOS   => httpd,
      Debian   => apache2,
      default => httpd
    }

    $phpmysql = $::operatingsystem ? {
      Ubuntu   => php5-mysql,
      CentOS   => php-mysql,
      Debian   => php5-mysql,
      default => php-mysql
    }

    $php = $::operatingsystem ? {
      Ubuntu   => libapache2-mod-php5,
      CentOS   => php,
      Debian   => libapache2-mod-php5,
      default => php
    }

    package { ['unzip',$apache,$php,$phpmysql]:
      ensure => latest
    }
}
#wordpress class shouldn't touch apache, should be a different module
==
$files = [ '/etc/mysql', '/var/log/mysql',
'/var/run/mysql' ]

file { $files:
 ensure => present,
 user   => mysql,
 group => mysql,
 mode   => 0755,
}
==
#arrays of resources are not wrong, but dangerous.

file { '/etc/mysql':
 ensure => present,
 user   => mysql,
 group => mysql,
 mode   => 0700, <=== careful with this!
}

file { '/var/log/mysql':
 ensure => present,
 user   => mysql,
 group => mysql,
 mode   => 0755,
}

file { '/var/run/mysql':
 ensure => present,
 user   => mysql,
 group => mysql,
 mode   => 0755,
}
==

if defined(File['/tmp/foo']) {
 notify('This configuration includes the /tmp/foo file.')
} else {
 file {'/tmp/foo':
   ensure => present,
 }
}
==
class test {

       if defined(File['/tmp/foo']) {
        notice('This configuration includes the /tmp/foo file.')
       } else {
        file {'/tmp/foo':
          ensure => present,
               group => root
        }
       }

       if defined(File['/tmp/foo']) {
        notice('This configuration includes the /tmp/foo file.')
       } else {
        file {'/tmp/foo':
          ensure => present,
               group => puppet
        }
       }
}

include test


defined() is (usually) the wrong solution to a resource defined in two locations. It is
dangerous, because it only checks if the resource has been defined elsewhere, not with
what attributes.
==

class apache2 {

file { '/etc/apache2':
 ensure => directory,
 require => Service['apache2']
}

file { '/etc/apache2/apache2.conf':
 ensure => present,
 require => File['/etc/apache2'],
 notify => Service['apache2'],
}

package { 'apache2':
 ensure => present,
 allowcdrom => true,
 before => File['/etc/apache2/apache2.conf']
}

service { 'apache2':
 ensure    => running,
 subscribe => File['/etc/apache2/apache2.conf']
}
}

include apache2
==
# dependency loop

class apache2 {

file { '/etc/apache2':
 ensure => directory,
 require => Service['apache2']
}

file { '/etc/apache2/apache2.conf':
 ensure => present,
 require => File['/etc/apache2'],
 notify => Service['apache2'], # <=== The notify metaparameter implies before.
}

package { 'apache2':
 ensure => present,
 allowcdrom => true,
 before => File['/etc/apache2/apache2.conf']
}

service { 'apache2':
 ensure    => running,
 subscribe => File['/etc/apache2/apache2.conf']   # <=== The subscribe metaparameter implies
require.
class test {

    file { '/tmp/somefile.txt':
      ensure => 'file',
      mode    => 0600,
      owner   => 'root',
      group   => 'root',
      source => '/etc/puppet/modules/test/somefile.txt'
    }

}

include test
==

# use puppet:///modules/ instead of the full path on the puppet master

class test {

    file { '/tmp/somefile.txt':
      ensure => 'file',
      mode    => 0600,
      owner   => 'root',
      group   => 'root',
      source => 'puppet:///modules/test/somefile.txt'
    }

}

include test
==
class test {
         file {‘/tmp/large/dir/with/many/subdirs/and/many/files’:
           ensure => present,
                owner   => root,
                group   => root,
                recurse => true
         }
}

include test
==

# do not use recurse => true on a dir with over 100+ files

class test {

        file {‘/tmp/large/dir/with/many/files’:
          ensure => present,
               owner   => root,
               group   => root,
               recurse => true
        }
}

include test

# alternative :’(

class test {

        exec {'/bin/chown -R root:root /tmp/large/dir/with/many/files':
        }
}
Walter Heck - OlinData
 Email: walterheck@olindata.com
 Twitter: @walterheck / @olindata
     Web: http://olindata.com
Questions? Feel free to get in touch!

More Related Content

What's hot

PuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetPuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with Puppet
Walter Heck
 
Anatomy of a reusable module
Anatomy of a reusable moduleAnatomy of a reusable module
Anatomy of a reusable module
Alessandro Franceschi
 
#SPUG - Legacy applications
#SPUG - Legacy applications#SPUG - Legacy applications
#SPUG - Legacy applications
Piotr Pasich
 
Drupal Camp Brighton 2015: Ansible Drupal Medicine show
Drupal Camp Brighton 2015: Ansible Drupal Medicine showDrupal Camp Brighton 2015: Ansible Drupal Medicine show
Drupal Camp Brighton 2015: Ansible Drupal Medicine show
George Boobyer
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
Ian Barber
 
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
Puppet
 
More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricks
bcoca
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
Puppet
 
feature toggles for ops
feature toggles for opsfeature toggles for ops
feature toggles for ops
Bram Vogelaar
 
Hadoop completereference
Hadoop completereferenceHadoop completereference
Hadoop completereference
arunkumar sadhasivam
 
Troubleshooting Puppet
Troubleshooting PuppetTroubleshooting Puppet
Troubleshooting Puppet
Thomas Howard Uphill
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
Alessandro Franceschi
 
Writing your own augeasproviders
Writing your own augeasprovidersWriting your own augeasproviders
Writing your own augeasproviders
Dominic Cleal
 
Utility Modules That You Should Know About
Utility Modules That You Should Know AboutUtility Modules That You Should Know About
Utility Modules That You Should Know About
joshua.mcadams
 
Medicine show2 Drupal Bristol Camp 2015
Medicine show2 Drupal Bristol Camp 2015Medicine show2 Drupal Bristol Camp 2015
Medicine show2 Drupal Bristol Camp 2015
George Boobyer
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
Wim Godden
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
Workhorse Computing
 
Docker for data science
Docker for data scienceDocker for data science
Docker for data science
Calvin Giles
 

What's hot (19)

dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
PuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetPuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with Puppet
 
Anatomy of a reusable module
Anatomy of a reusable moduleAnatomy of a reusable module
Anatomy of a reusable module
 
#SPUG - Legacy applications
#SPUG - Legacy applications#SPUG - Legacy applications
#SPUG - Legacy applications
 
Drupal Camp Brighton 2015: Ansible Drupal Medicine show
Drupal Camp Brighton 2015: Ansible Drupal Medicine showDrupal Camp Brighton 2015: Ansible Drupal Medicine show
Drupal Camp Brighton 2015: Ansible Drupal Medicine show
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
 
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
 
More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricks
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
 
feature toggles for ops
feature toggles for opsfeature toggles for ops
feature toggles for ops
 
Hadoop completereference
Hadoop completereferenceHadoop completereference
Hadoop completereference
 
Troubleshooting Puppet
Troubleshooting PuppetTroubleshooting Puppet
Troubleshooting Puppet
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
 
Writing your own augeasproviders
Writing your own augeasprovidersWriting your own augeasproviders
Writing your own augeasproviders
 
Utility Modules That You Should Know About
Utility Modules That You Should Know AboutUtility Modules That You Should Know About
Utility Modules That You Should Know About
 
Medicine show2 Drupal Bristol Camp 2015
Medicine show2 Drupal Bristol Camp 2015Medicine show2 Drupal Bristol Camp 2015
Medicine show2 Drupal Bristol Camp 2015
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
Docker for data science
Docker for data scienceDocker for data science
Docker for data science
 

Viewers also liked

PuppetCamp SEA @ Blk 71 - Puppet: The Year That Was
PuppetCamp SEA @ Blk 71 - Puppet: The Year That WasPuppetCamp SEA @ Blk 71 - Puppet: The Year That Was
PuppetCamp SEA @ Blk 71 - Puppet: The Year That Was
Walter Heck
 
PuppetCamp SEA @ Blk 71 - What's New in Puppet DB
PuppetCamp SEA @ Blk 71 - What's New in Puppet DBPuppetCamp SEA @ Blk 71 - What's New in Puppet DB
PuppetCamp SEA @ Blk 71 - What's New in Puppet DB
Walter Heck
 
PuppetCamp SEA @ Blk 71 - Cloud Management with Puppet
PuppetCamp SEA @ Blk 71 - Cloud Management with PuppetPuppetCamp SEA @ Blk 71 - Cloud Management with Puppet
PuppetCamp SEA @ Blk 71 - Cloud Management with Puppet
Walter Heck
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Walter Heck
 
PuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of PuppetPuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of Puppet
Walter Heck
 
PuppetCamp SEA 1 - Puppet & FreeBSD
PuppetCamp SEA 1 - Puppet & FreeBSDPuppetCamp SEA 1 - Puppet & FreeBSD
PuppetCamp SEA 1 - Puppet & FreeBSD
Walter Heck
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
Walter Heck
 
Puppet User Group Presentation - 15 March 2012
Puppet User Group Presentation - 15 March 2012Puppet User Group Presentation - 15 March 2012
Puppet User Group Presentation - 15 March 2012
Walter Heck
 
Compliance and auditing with Puppet
Compliance and auditing with PuppetCompliance and auditing with Puppet
Compliance and auditing with Puppet
Peter Souter
 

Viewers also liked (9)

PuppetCamp SEA @ Blk 71 - Puppet: The Year That Was
PuppetCamp SEA @ Blk 71 - Puppet: The Year That WasPuppetCamp SEA @ Blk 71 - Puppet: The Year That Was
PuppetCamp SEA @ Blk 71 - Puppet: The Year That Was
 
PuppetCamp SEA @ Blk 71 - What's New in Puppet DB
PuppetCamp SEA @ Blk 71 - What's New in Puppet DBPuppetCamp SEA @ Blk 71 - What's New in Puppet DB
PuppetCamp SEA @ Blk 71 - What's New in Puppet DB
 
PuppetCamp SEA @ Blk 71 - Cloud Management with Puppet
PuppetCamp SEA @ Blk 71 - Cloud Management with PuppetPuppetCamp SEA @ Blk 71 - Cloud Management with Puppet
PuppetCamp SEA @ Blk 71 - Cloud Management with Puppet
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with PuppetPuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
 
PuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of PuppetPuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of Puppet
 
PuppetCamp SEA 1 - Puppet & FreeBSD
PuppetCamp SEA 1 - Puppet & FreeBSDPuppetCamp SEA 1 - Puppet & FreeBSD
PuppetCamp SEA 1 - Puppet & FreeBSD
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
 
Puppet User Group Presentation - 15 March 2012
Puppet User Group Presentation - 15 March 2012Puppet User Group Presentation - 15 March 2012
Puppet User Group Presentation - 15 March 2012
 
Compliance and auditing with Puppet
Compliance and auditing with PuppetCompliance and auditing with Puppet
Compliance and auditing with Puppet
 

Similar to PuppetCamp Ghent - What Not to Do with Puppet

Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
Puppet fundamentals
Puppet fundamentalsPuppet fundamentals
Puppet fundamentals
Murali Boyapati
 
Tutorial Puppet
Tutorial PuppetTutorial Puppet
Tutorial Puppet
Daniel Sobral
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkMichael Peacock
 
Puppet
PuppetPuppet
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013
grim_radical
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011
Carlos Sanchez
 
DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet
DevOps: Falando um pouco sobre desenvolvimento orientado a testes com PuppetDevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet
DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet
Marcelo Andrade
 
From Dev to DevOps
From Dev to DevOpsFrom Dev to DevOps
From Dev to DevOps
Agile Spain
 
20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasaggarrett honeycutt
 
Creating beautiful puppet modules with puppet-lint
Creating beautiful puppet modules with puppet-lintCreating beautiful puppet modules with puppet-lint
Creating beautiful puppet modules with puppet-lint
Spencer Owen
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011
Carlos Sanchez
 
Using Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSXUsing Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSX
Puppet
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
Alessandro Franceschi
 
Puppi. Puppet strings to the shell
Puppi. Puppet strings to the shellPuppi. Puppet strings to the shell
Puppi. Puppet strings to the shell
Alessandro Franceschi
 
Hadoop installation
Hadoop installationHadoop installation
Hadoop installation
habeebulla g
 

Similar to PuppetCamp Ghent - What Not to Do with Puppet (20)

Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012
 
Puppet fundamentals
Puppet fundamentalsPuppet fundamentals
Puppet fundamentals
 
Tutorial Puppet
Tutorial PuppetTutorial Puppet
Tutorial Puppet
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
 
Puppet
PuppetPuppet
Puppet
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
 
Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011
 
DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet
DevOps: Falando um pouco sobre desenvolvimento orientado a testes com PuppetDevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet
DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet
 
From Dev to DevOps
From Dev to DevOpsFrom Dev to DevOps
From Dev to DevOps
 
20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag
 
Puppet
PuppetPuppet
Puppet
 
Creating beautiful puppet modules with puppet-lint
Creating beautiful puppet modules with puppet-lintCreating beautiful puppet modules with puppet-lint
Creating beautiful puppet modules with puppet-lint
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
 
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012
 
From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011
 
Using Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSXUsing Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSX
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
Puppi. Puppet strings to the shell
Puppi. Puppet strings to the shellPuppi. Puppet strings to the shell
Puppi. Puppet strings to the shell
 
Hadoop installation
Hadoop installationHadoop installation
Hadoop installation
 

Recently uploaded

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 

Recently uploaded (20)

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 

PuppetCamp Ghent - What Not to Do with Puppet

  • 1. Puppet: What _not_ to do? An interactive journey through the ugly side of Puppet
  • 2. •Walter Heck, Founder of OlinData •2,5 years experience with Puppet in 5+ different environments •Experienced Puppet Fundamentals trainer •Had my eyes bleed many times with ugly Puppet code
  • 3. Design mistakes might not be glaringly obvious or even wrong at first, but will cause trouble later • Language mistakes Puppet provides functionality that shouldn't be used, but is there for edge- cases or historical purposes
  • 4. Quiz time! Wake up...
  • 5. == File: modules/ssh/manifests/ssh.pp class ssh_install { package { 'ssh': ensure => present } } class ssh_configure { file { '/etc/ssh/sshd_config': ensure => present } }
  • 6. == File: modules/ssh/manifests/ssh.pp class ssh($state = ‘present’ { package { 'ssh': ensure => $state } file { '/etc/ssh/sshd_config': ensure => $state } } # problem: classnames won't be autoloaded, classnames shouldn't have verbs in them, classes should be combined, don't put multiple classes in a file
  • 7. == schedule { 'maint': range => '2 - 4', period => daily, repeat => 1, } exec { '/usr/bin/apt-get update': schedule => 'maint', }
  • 8. == schedule { 'maint': range => '2 - 4', period => daily, repeat => 1, } exec { '/usr/bin/apt-get update': schedule => 'maint', } # problem: schedule doesn't mean something will execute, a common pitfall. If there is no puppet run between these hours, the apt-get exec will not be run
  • 9. == $myvar = ‘false’ if ($myvar) { notice(‘this is true’) } else { notice(‘This is false’) }
  • 10. == $myvar = ‘false’ if ($myvar) { notice(‘this is true’) } else { notice(‘This is false’) } #problem: 'false' evaluates to true
  • 11. == exec { '/etc/init.d/apache start': onlyif => ‘ps aux | grep apache | grep -v grep | wc -l’ }
  • 12. == exec { '/etc/init.d/apache start': onlyif => ‘ps aux | grep apache | grep -v grep | wc -l’ } # problem: this shouldn't be an exec, but a service
  • 13. == package { 'ssh': ensure => present, name => $::operatingsystem ? { 'Ubuntu' => 'openssh-server', default => 'ssh', }, }
  • 14. == $sshpkgname = $::operatingsystem ? { 'Ubuntu' => 'openssh-server', default => undef, } if ($sshpkgname == undef) { fail(‘unsupported OS’) } else { package { 'ssh': ensure => present, name => $sshpkgname, } } #problem: they encourage behaviour that is not scalable, using default options to assume things, etc.
  • 15. == case $::operatingsystem { 'RedHat', 'CentOS': { file { ‘/etc/httpd/http.conf’: ensure => ‘present’, } } default: { file { ‘/etc/apache2/apache2.conf’: ensure => ‘present’, } } }
  • 16. == case $::operatingsystem { 'RedHat', 'CentOS': { file { ‘/etc/httpd/http.conf’: ensure => ‘present’, } } default: { file { ‘/etc/apache2/apache2.conf’: ensure => ‘present’, } } } #problem: case without default that fails, instead it assumes
  • 17. == class wordpress { $wordpress_archive = 'wordpress-3.4.1.zip' $apache = $::operatingsystem ? { Ubuntu => apache2, CentOS => httpd, Debian => apache2, default => httpd } $phpmysql = $::operatingsystem ? { Ubuntu => php5-mysql, CentOS => php-mysql, Debian => php5-mysql, default => php-mysql } $php = $::operatingsystem ? { Ubuntu => libapache2-mod-php5, CentOS => php, Debian => libapache2-mod-php5, default => php } package { ['unzip',$apache,$php,$phpmysql]: ensure => latest } }
  • 18. == class wordpress { $wordpress_archive = 'wordpress-3.4.1.zip' $apache = $::operatingsystem ? { Ubuntu => apache2, CentOS => httpd, Debian => apache2, default => httpd } $phpmysql = $::operatingsystem ? { Ubuntu => php5-mysql, CentOS => php-mysql, Debian => php5-mysql, default => php-mysql } $php = $::operatingsystem ? { Ubuntu => libapache2-mod-php5, CentOS => php, Debian => libapache2-mod-php5, default => php } package { ['unzip',$apache,$php,$phpmysql]: ensure => latest } } #wordpress class shouldn't touch apache, should be a different module
  • 19. == $files = [ '/etc/mysql', '/var/log/mysql', '/var/run/mysql' ] file { $files: ensure => present, user => mysql, group => mysql, mode => 0755, }
  • 20. == #arrays of resources are not wrong, but dangerous. file { '/etc/mysql': ensure => present, user => mysql, group => mysql, mode => 0700, <=== careful with this! } file { '/var/log/mysql': ensure => present, user => mysql, group => mysql, mode => 0755, } file { '/var/run/mysql': ensure => present, user => mysql, group => mysql, mode => 0755, }
  • 21. == if defined(File['/tmp/foo']) { notify('This configuration includes the /tmp/foo file.') } else { file {'/tmp/foo': ensure => present, } }
  • 22. == class test { if defined(File['/tmp/foo']) { notice('This configuration includes the /tmp/foo file.') } else { file {'/tmp/foo': ensure => present, group => root } } if defined(File['/tmp/foo']) { notice('This configuration includes the /tmp/foo file.') } else { file {'/tmp/foo': ensure => present, group => puppet } } } include test defined() is (usually) the wrong solution to a resource defined in two locations. It is dangerous, because it only checks if the resource has been defined elsewhere, not with what attributes.
  • 23. == class apache2 { file { '/etc/apache2': ensure => directory, require => Service['apache2'] } file { '/etc/apache2/apache2.conf': ensure => present, require => File['/etc/apache2'], notify => Service['apache2'], } package { 'apache2': ensure => present, allowcdrom => true, before => File['/etc/apache2/apache2.conf'] } service { 'apache2': ensure => running, subscribe => File['/etc/apache2/apache2.conf'] } } include apache2
  • 24. == # dependency loop class apache2 { file { '/etc/apache2': ensure => directory, require => Service['apache2'] } file { '/etc/apache2/apache2.conf': ensure => present, require => File['/etc/apache2'], notify => Service['apache2'], # <=== The notify metaparameter implies before. } package { 'apache2': ensure => present, allowcdrom => true, before => File['/etc/apache2/apache2.conf'] } service { 'apache2': ensure => running, subscribe => File['/etc/apache2/apache2.conf'] # <=== The subscribe metaparameter implies require.
  • 25. class test { file { '/tmp/somefile.txt': ensure => 'file', mode => 0600, owner => 'root', group => 'root', source => '/etc/puppet/modules/test/somefile.txt' } } include test
  • 26. == # use puppet:///modules/ instead of the full path on the puppet master class test { file { '/tmp/somefile.txt': ensure => 'file', mode => 0600, owner => 'root', group => 'root', source => 'puppet:///modules/test/somefile.txt' } } include test
  • 27. == class test { file {‘/tmp/large/dir/with/many/subdirs/and/many/files’: ensure => present, owner => root, group => root, recurse => true } } include test
  • 28. == # do not use recurse => true on a dir with over 100+ files class test { file {‘/tmp/large/dir/with/many/files’: ensure => present, owner => root, group => root, recurse => true } } include test # alternative :’( class test { exec {'/bin/chown -R root:root /tmp/large/dir/with/many/files': } }
  • 29. Walter Heck - OlinData Email: walterheck@olindata.com Twitter: @walterheck / @olindata Web: http://olindata.com Questions? Feel free to get in touch!