SlideShare a Scribd company logo
1 of 24
class puppet { 'at SimilarWeb':
name => 'shamil',
ensure => present,
require => Group['devops']
}
Before we dive in
Let’s talk about Puppet DSL gotchas
What is Puppet DSL
● Configuration language
● Declarative as possible
● Similar to how you write configuration files
● Can be extended with Ruby API
Building blocks:
● Resources
● Classes
● Nodes
Official Docs:
https://docs.puppetlabs.com/puppet/3.8/reference/lang_summary.html
Resources, Classes & Nodes
Resources:
The fundamental unit for modeling system configurations. Each resource
describes some aspect of a system, like a service that must be running or a
package that must be installed.
Classes:
Group of resources.
Nodes:
Built-in node classification.
Built-in resource types
Example
# Class
class java($version = '1.7') {
# Resource
package { 'jdk':
ensure => $version
}
}
# Built-in node classificator
node default {
include java
}
# Include like
include java
# Resource like
class { 'java': }
VS
Declaring Classes
include java
include java
Multiple class declarations
class { 'java': }
include java
include java
class { 'java': }
include java
include java
Multiple class declarations
class { 'java': }
include java
include java
class { 'java': }
include java
include java
Multiple class declarations
class { 'java': }
include java
include java
class { 'java': }
include java
include java
Multiple class declarations
class { 'java': }
include java
include java
class { 'java': }
Namespacing
class hadoop::java {
`include java
}
Namespacing
class hadoop::java {
include java
}
class hadoop::java {
include hadoop::java
}
Namespacing
class hadoop::java {
include java
}
class hadoop::java {
include hadoop::java
}
class hadoop::java {
include ::java
}
Puppet
Roles and Profiles pattern
Design diagram
Resources
Component Modules
Profiles: Group of components
Roles: Group of profiles
(represent Business Logic)
Node classifier
(built-in, or external)
Hiera
(data)
Resource Example
package { 'ntp':
ensure => installed,
notify => Service['ntpd']
}
Component Example
class ntp ($ntp_server) {
package { 'ntp':
ensure => installed
}
augeas { '/etc/ntp.conf':
incl => '/etc/ntp.conf',
lens => 'Ntp.lns',
changes => ['rm server[.]', "set server ${ntp_server}"],
require => Package['ntp'],
notify => Service['ntpd']
}
service { 'ntpd':
name => $::osfamily ? { 'Debian' => ntp, 'RedHat' => ntpd },
ensure => running,
enable => true,
require => Augeas['/etc/ntp.conf']
}
}
Profile Example
class profiles::base::ntp {
$server = hiera('profiles::base::ntp::server')
class ::ntp {
ntp_server => $server
}
}
Hiera Example
# /etc/puppet/hiera.yaml
:backends: yaml
:yaml:
:datadir: /etc/puppet/hiera
:hierarchy:
- "node/%{::clientcert}"
- "environment/%{::env}"
- common
# /etc/puppet/hiera/common.yaml
profiles::base::ntp::server: "ins1.sg.internal"
Role Example
class roles::generic_server {
include profiles::base::ntp
include profiles::base::zabbix_agent
include profiles::security::firewall
}
Built-in Classifier Example
node default {
include roles::generic_server
}
Check this out
R10K - Puppet environment and module deployment:
https://github.com/puppetlabs/r10k
Doing the Refactor Dance:
https://puppetlabs.com/presentations/workshop-doing-refactor-dance-making-
your-puppet-modules-more-modular-gary-larizza
Gary’s Larizza blog:
http://garylarizza.com/
Thank you
presented by Alex Simenduev
- github.com/shamil
- linkedin.com/in/simenduev

More Related Content

What's hot

Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5Jason Austin
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
Dependency injection in Drupal 8
Dependency injection in Drupal 8Dependency injection in Drupal 8
Dependency injection in Drupal 8Alexei Gorobets
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09Bastian Feder
 
Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Martin Alfke
 
Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Adam Tomat
 
Streams, sockets and filters oh my!
Streams, sockets and filters oh my!Streams, sockets and filters oh my!
Streams, sockets and filters oh my!Elizabeth Smith
 
SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09Elizabeth Smith
 
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Balázs Tatár
 
A Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpA Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpMichael Girouard
 
Moodle 3.3 - API Change Overview #mootieuk17
Moodle 3.3 - API Change Overview #mootieuk17Moodle 3.3 - API Change Overview #mootieuk17
Moodle 3.3 - API Change Overview #mootieuk17Dan Poltawski
 
Puppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet Camp Berlin 2014: Manageable puppet infrastructurePuppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet Camp Berlin 2014: Manageable puppet infrastructurePuppet
 

What's hot (20)

Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
 
Anatomy of a reusable module
Anatomy of a reusable moduleAnatomy of a reusable module
Anatomy of a reusable module
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
Dependency injection in Drupal 8
Dependency injection in Drupal 8Dependency injection in Drupal 8
Dependency injection in Drupal 8
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09
 
Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?
 
Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018
 
Power of Puppet 4
Power of Puppet 4Power of Puppet 4
Power of Puppet 4
 
Puppet modules for Fun and Profit
Puppet modules for Fun and ProfitPuppet modules for Fun and Profit
Puppet modules for Fun and Profit
 
What's new with PHP7
What's new with PHP7What's new with PHP7
What's new with PHP7
 
Streams, sockets and filters oh my!
Streams, sockets and filters oh my!Streams, sockets and filters oh my!
Streams, sockets and filters oh my!
 
Intro to-puppet
Intro to-puppetIntro to-puppet
Intro to-puppet
 
SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09
 
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
 
Puppi. Puppet strings to the shell
Puppi. Puppet strings to the shellPuppi. Puppet strings to the shell
Puppi. Puppet strings to the shell
 
A Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpA Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented Php
 
Moodle 3.3 - API Change Overview #mootieuk17
Moodle 3.3 - API Change Overview #mootieuk17Moodle 3.3 - API Change Overview #mootieuk17
Moodle 3.3 - API Change Overview #mootieuk17
 
2012 03 08_dbi
2012 03 08_dbi2012 03 08_dbi
2012 03 08_dbi
 
Puppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet Camp Berlin 2014: Manageable puppet infrastructurePuppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet Camp Berlin 2014: Manageable puppet infrastructure
 
Php go vrooom!
Php go vrooom!Php go vrooom!
Php go vrooom!
 

Viewers also liked

Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternPuppet
 
Puppetconf2016 Puppet on Windows
Puppetconf2016 Puppet on WindowsPuppetconf2016 Puppet on Windows
Puppetconf2016 Puppet on WindowsNicolas Corrarello
 
Puppet for Everybody! - Federated and Hierarchical Puppet Enterprise - Puppet...
Puppet for Everybody! - Federated and Hierarchical Puppet Enterprise - Puppet...Puppet for Everybody! - Federated and Hierarchical Puppet Enterprise - Puppet...
Puppet for Everybody! - Federated and Hierarchical Puppet Enterprise - Puppet...Puppet
 
Case Study: Green Field Implementation of Puppet 3.0 at ESPN
Case Study: Green Field Implementation of Puppet 3.0 at ESPNCase Study: Green Field Implementation of Puppet 3.0 at ESPN
Case Study: Green Field Implementation of Puppet 3.0 at ESPNPuppet
 
Pro Puppet
Pro PuppetPro Puppet
Pro Puppetdsadas
 
PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...
PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...
PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...Puppet
 
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...Puppet
 
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, PuppetPuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, PuppetPuppet
 
Managing Windows Systems with Puppet - PuppetConf 2013
Managing Windows Systems with Puppet - PuppetConf 2013Managing Windows Systems with Puppet - PuppetConf 2013
Managing Windows Systems with Puppet - PuppetConf 2013Puppet
 
Puppet Design Patterns
Puppet Design PatternsPuppet Design Patterns
Puppet Design PatternsDavid Danzilio
 

Viewers also liked (10)

Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles Pattern
 
Puppetconf2016 Puppet on Windows
Puppetconf2016 Puppet on WindowsPuppetconf2016 Puppet on Windows
Puppetconf2016 Puppet on Windows
 
Puppet for Everybody! - Federated and Hierarchical Puppet Enterprise - Puppet...
Puppet for Everybody! - Federated and Hierarchical Puppet Enterprise - Puppet...Puppet for Everybody! - Federated and Hierarchical Puppet Enterprise - Puppet...
Puppet for Everybody! - Federated and Hierarchical Puppet Enterprise - Puppet...
 
Case Study: Green Field Implementation of Puppet 3.0 at ESPN
Case Study: Green Field Implementation of Puppet 3.0 at ESPNCase Study: Green Field Implementation of Puppet 3.0 at ESPN
Case Study: Green Field Implementation of Puppet 3.0 at ESPN
 
Pro Puppet
Pro PuppetPro Puppet
Pro Puppet
 
PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...
PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...
PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...
 
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...
 
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, PuppetPuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
 
Managing Windows Systems with Puppet - PuppetConf 2013
Managing Windows Systems with Puppet - PuppetConf 2013Managing Windows Systems with Puppet - PuppetConf 2013
Managing Windows Systems with Puppet - PuppetConf 2013
 
Puppet Design Patterns
Puppet Design PatternsPuppet Design Patterns
Puppet Design Patterns
 

Similar to Puppet DSL Gotchas and Best Practices

modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet CampPuppet
 
Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerGaryCoady
 
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 2012Carlos 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 2011Carlos Sanchez
 
Rowan: A new project/package manager
Rowan: A new project/package managerRowan: A new project/package manager
Rowan: A new project/package managerESUG
 
Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Tino Isnich
 
Development of Java tools using SWT and WALA af Hans Søndergaard, ViaUC
Development of Java tools using SWT and WALA af Hans Søndergaard, ViaUCDevelopment of Java tools using SWT and WALA af Hans Søndergaard, ViaUC
Development of Java tools using SWT and WALA af Hans Søndergaard, ViaUCInfinIT - Innovationsnetværket for it
 
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 2012Carlos Sanchez
 
Alphorm.com Formation React Testing Library
Alphorm.com Formation React Testing LibraryAlphorm.com Formation React Testing Library
Alphorm.com Formation React Testing LibraryAlphorm
 
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdfdokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdfAppster1
 
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdfdokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdfAppster1
 
OSGi ecosystems compared on Apache Karaf - Christian Schneider
OSGi ecosystems compared on Apache Karaf - Christian SchneiderOSGi ecosystems compared on Apache Karaf - Christian Schneider
OSGi ecosystems compared on Apache Karaf - Christian Schneidermfrancis
 
SCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitSCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitMike Pfaff
 

Similar to Puppet DSL Gotchas and Best Practices (20)

Resthub lyonjug
Resthub lyonjugResthub lyonjug
Resthub lyonjug
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
 
Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packager
 
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
 
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
 
GradleFX
GradleFXGradleFX
GradleFX
 
Cis 274 intro
Cis 274   introCis 274   intro
Cis 274 intro
 
Angular Schematics
Angular SchematicsAngular Schematics
Angular Schematics
 
Rowan: A new project/package manager
Rowan: A new project/package managerRowan: A new project/package manager
Rowan: A new project/package manager
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01
 
Development of Java tools using SWT and WALA af Hans Søndergaard, ViaUC
Development of Java tools using SWT and WALA af Hans Søndergaard, ViaUCDevelopment of Java tools using SWT and WALA af Hans Søndergaard, ViaUC
Development of Java tools using SWT and WALA af Hans Søndergaard, ViaUC
 
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
 
Alphorm.com Formation React Testing Library
Alphorm.com Formation React Testing LibraryAlphorm.com Formation React Testing Library
Alphorm.com Formation React Testing Library
 
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdfdokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
 
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdfdokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
OSGi ecosystems compared on Apache Karaf - Christian Schneider
OSGi ecosystems compared on Apache Karaf - Christian SchneiderOSGi ecosystems compared on Apache Karaf - Christian Schneider
OSGi ecosystems compared on Apache Karaf - Christian Schneider
 
SCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitSCR Annotations for Fun and Profit
SCR Annotations for Fun and Profit
 

Puppet DSL Gotchas and Best Practices