SlideShare a Scribd company logo
The Power of Puppet 4
Martin Alfke
ma@example42.com Image: http://praetoris01.deviantart.com/
Martin Alfke
PL Training Partner
Module Contributor
!
ex-System Engineer
Infrastructure Architect
Welcome to Puppet 4
April 15th 2015
https://puppetlabs.com/
blog/say-hello-open-
source-puppet-4
http://
docs.puppetlabs.com/
puppet/4.0/reference/
index.html
Puppet Server & Packages
Puppet Server on JVM
Clojure
Trapperkeeper
JMX & internal metrics
(PE only)
Puppet Packaging
AIO - like PE
New package name
New repository layout
No automatic update
Environments
Config environments
Static puppet.conf
[production]
modulepath = /etc/puppet/production/modules
manifests = /etc/puppet/production/manifests/site.pp
!
[test]
modulepath = /etc/puppet/test/modules
manifests = /etc/puppet/test/manifests/site.pp
Config environments
Dynamic puppet.conf
[master]
modulepath = /etc/puppet/$environment/modules
manifests = /etc/puppet/$environment/manifests/site.pp
!
Directory environments
puppet.conf
[master]
environmentpath = /etc/puppet/environments
!
File system
/etc/puppet/environments/
	 	 	 	 	 production/
	 	 	 	 	 	 	 modules/
	 	 	 	 	 	 	 manifests/
	 	 	 	 	 	 	 environment.conf
	 	 	 	 	 test/
	 	 	 	 	 	 	 modules/
	 	 	 	 	 	 	 manifests/
Directory
Benefits
All environments in one place
Per environment configuration (environment.conf)
config_version = '/usr/bin/git --git-dir /etc/puppet/environments/
$environment/.git rev-parse HEAD'
Newly added environments are available immediately
r10k
Robot 10000
Manage environment in git branches
Puppetfile handles modules and versions
New language features
Lambdas
Lambda
“a block of code that has parameters and can be invoked/called with arguments. A
single lambda can be passed to a function”
	 $a = [1,2,3]
	 each($a) |value| {notice $value }
Lambdas and functions
each - iterating over an array
map - transform an array or hash into a new array
filter - filters an array or hash
reduce - reduces an array or hash to a single value
slice - slices an array or hash into chunks
Using functions
Standard Puppet way:
function_name(argument) - each($variable)
Ruby way - chaining
argument.function_name - $variable.each
EPP Template engine
Use Puppet $var instead of Ruby ERB @var
epp(filename)
inline_epp(epp_string)
HEREDOC support
Like Shell HEREDOC
$multiline_text = @(EOF)
# Managed by Puppet
intended two spaces
starting at beginning of line
| intention starts at pipe sign
EOF
HEREDOC control character
- prevents a new line (like erb/epp)
@(“EOF”) - variable substition
@(EOF/tn) - enables char escapes
availabe char escapes: t,s,r,n,u,L,$
Default to off
Puppet 4.0 Data Bindings
New “hierarchy”:
global data (hiera)
data in environment (environment.conf)
data in modules
Puppet 4.0 Data in Env
environment.conf
environment_data_provider = function
<env-root>/lib/puppet/functions/environment/data.rb
Puppet::Function.create_function(:’environment::data’) do
	 def data ()
	 	 {
	 	 	 ‘<class>::key’ => ‘value’,
	 	 }
	 end
end
$variable = environment::data(‘key’)	 or	 automatic data bindings
Puppet 4.0 Data in Modules
<moduleroot>/lib/puppet/bindings/mymodule/default.rb
Puppet::Bindings.newbindings(‘mymodule::default’) do … end
<moduleroot>/lib/puppet/functions/mymodule/data.rb
Puppet::Functions.create_function(:’mymodule::data’) do
	 def data()
	 	 {
	 	 	 ‘mymodule::<class>::key’ => ‘value’,
	 	 }
	 end
end
!
$var = mymodule::data(‘key’)	 or	 automatic data bindings
Puppet 4.0 Data Overriding
<env-root>/lib/puppet/functions/environment/data.rb
Puppet::Functions.create_function(:’environment::data’) do
	 def data()
	 	 {
	 	 	 ‘<module>::<class>::key’ => ‘value’,
	 	 }
	 end
end
!
used with automatic data bindings
Types, Types, Types
Why do we need types?
class ssh (
	 $server = true,
) {
	 if $server {
	 	 include ssh::server
	 }
}
Parameterized class with parameter default
Why do we need types?
class ssh (
	 $server = true,
) {
	 if $server {
	 	 include ssh::server
	 }
}
!
!
class { ‘ssh’:
	 server => ‘false’,
}
!
!
!
!
!
!
!
!
!
Usage of parameterised class. But: string
instead of boolean !
Why do we need types?
class ssh (
	 $server = true,
) {
	 if validate_bool($server) {
	 	 include ssh::server
	 }
}
!
!
class { ‘ssh’:
	 server => ‘false’,
}
Parameterized class with parameter default
!
!
Now with data validation (from stdlib)
Why do we need types?
users::hash:
‘tom’:
gid: ‘123’
home: ‘/home/tom’
managehome: false
‘ben’:
gid: ‘124’
home: /home/ben
managehome: ‘true’
‘tim’:
gid: 0125
home: ‘home/tim’
managehome: ‘false’
But: how to deal with more complex data?
!
!
!
!
!
!
Missing quotes
String instead of bool
!
Missing quotes and leading 0
Missing trailing slash
String instead of bool
We need types!
class ssh (
	 Boolean $server = true,
) {
	 if $server {
	 	 include ssh::server
	 }
}
!
Types, Types, Types, Types
We need types!
class ssh (
	 Boolean $server = true,
) {
	 if $server {
	 	 include ssh::server
	 }
}
!
!
class { ‘ssh’:
	 server => ‘false’,
}
!
Error 400 on SERVER: Expected parameter 'server' of
'Class[Ssh]' to have type Boolean, got String
!
!
!
!
!
!
!
!
!
We now get proper error messages.
We want types!
class users (
Hash $hash
) {
$userarray = keys($hash)
users::user_data { $userarray: }
}
!
define users::user_data (
String $gid = $users::hash[$title][gid],
String $home = $users::hash[$title][home],
Boolean $managehome = $users::hash[$title][managehome],
) {
}
Available Types
Integer[from, to]
Float[from,to]
Enum[*strings]
Pattern[*patterns]
Regexp[regexp]
Boolean
Array
Hash
Deprecations
Node Inheritance
node ‘basenode’ {
include base
include security
}
!
node ‘www.server.com’ inherits basenode {
include webserver
}
# Dummy node as default
!
!
!
!
# Real node inherits from basenode
Roles & Profiles
node ‘www.server.com’ {
include webserver
}
!
!
class basenode {
include base
include security
}
!
class webserver {
include basenode
}
# No more node inheritance
!
!
!
!
# Define a class instead
Empty string comparison
An empty string compares to true instead of false
Empty string comparison
$message = ‘’
!
if $message {
notify { “Message: ${message}”: }
}
Empty string set as default
!
Check for variable existing and having
content
Empty string comparison
$message = ‘’
!
if $message and $message != ‘’ {
notify { “Message: ${message}”: }
}
Empty string set as default
!
Check for variable existing and not empty
string
Variable naming
A variable may not start with
a capital letter
an underscore (well. yes. it may. but. it’s private.)
Reference naming
Reference deprecation
capital letter on title
empty space between Type reference and title
!
Class [Ssh]
!
Class [‘ssh’]
!
Class[‘ssh’]
!
Deprecated capital title
!
Empty space
!
Working
Hyphens in names
No more hyphens in
module name
class name
define name
Hyphens in names
!
<modulepath>/syslog-ng/
!
<modulepath>/syslog_ng
!
class syslog-ng { … }
!
class syslog_ng { … }
!
Deprecated
!
New name required
!
Deprecated
!
New name required (obious -> module/
class naming convention)
Ruby DSL
Puppet Ticket #18876
Closed 02/04/2013
New Ruby DSL API was revamped: “the number and
severity of issues that came up in exploratory testing
led us to the conclusion that it was not supportable
code” - Puppet Dev ML - 01/26/2013
	 	 hostclass ‘ssh’ do
	 	 end
More deprecation
Relative resolution of class names - the reason why
you want to use double colon - include ::ssh
Importing manifests
Matching numbers with regexp
Search function
Mutating arrays and hashes
The 4 Powers of Puppet 4
Performance
Request response times and catalog compile times
!
!
Scalability
Switch on/off functionality for multi master setup
!
!
!
Measurability
Flexibility
Dealing with complex data natively in Puppet DSL
Upgrading to Puppet 4
Breaks old style Puppet
DSL code
Read documentation
carefully
Run tests
Proposed way: new
master
Text
Support all modules
Write PR, file bug reports, fix issues
More information
https://docs.puppetlabs.com/puppet/3.7/reference/
deprecated_language.html
http://puppet-on-the-edge.blogspot.de/
http://docs.puppetlabs.com/puppet/4.0/reference/
index.html
https://puppetlabs.com/blog/welcome-puppet-
collections
Text
The Power of Puppet 4
Martin Alfke
ma@example42.com
Image: http://praetoris01.deviantart.com/

More Related Content

PDF
Puppet Camp Berlin 2015: Martin Alfke | The Power of Puppet 4
PDF
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
PDF
Perl.Hacks.On.Vim
PPTX
Migrating to Puppet 4.0
PDF
Ruby 2.0
PDF
Metadata-driven Testing
PDF
Hypers and Gathers and Takes! Oh my!
PDF
Good Evils In Perl
Puppet Camp Berlin 2015: Martin Alfke | The Power of Puppet 4
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Perl.Hacks.On.Vim
Migrating to Puppet 4.0
Ruby 2.0
Metadata-driven Testing
Hypers and Gathers and Takes! Oh my!
Good Evils In Perl

What's hot (19)

PDF
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...
PDF
関西PHP勉強会 php5.4つまみぐい
PDF
Findbin libs
PDF
Power of Puppet 4
PDF
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
PDF
BSDM with BASH: Command Interpolation
PPTX
Bioinformatics p1-perl-introduction v2013
ODP
Introduction to Perl - Day 1
PDF
Memory Manglement in Raku
PPSX
Symfony2 meets propel 1.5
PDF
Introduction to Perl and BioPerl
PDF
BASH Variables Part 1: Basic Interpolation
PDF
Perl6 Regexen: Reduce the line noise in your code.
PDF
Zend Certification Preparation Tutorial
PDF
Object Trampoline: Why having not the object you want is what you need.
PDF
SPL to the Rescue - Tek 09
PDF
PHP 8.1 - What's new and changed
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...
関西PHP勉強会 php5.4つまみぐい
Findbin libs
Power of Puppet 4
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
BSDM with BASH: Command Interpolation
Bioinformatics p1-perl-introduction v2013
Introduction to Perl - Day 1
Memory Manglement in Raku
Symfony2 meets propel 1.5
Introduction to Perl and BioPerl
BASH Variables Part 1: Basic Interpolation
Perl6 Regexen: Reduce the line noise in your code.
Zend Certification Preparation Tutorial
Object Trampoline: Why having not the object you want is what you need.
SPL to the Rescue - Tek 09
PHP 8.1 - What's new and changed
Ad

Similar to Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) (20)

PDF
Puppet Camp Berlin 2015: The Power of Puppet 4
PDF
Puppet Camp Amsterdam 2015: The Power of Puppet 4 (Beginner)
PDF
Can you upgrade to Puppet 4.x?
ODP
Introduction to Modern Perl
PDF
Puppet Camp Duesseldorf 2014: Martin Alfke - Can you upgrade to puppet 4.x?
PPT
Bioinformatica 10-11-2011-p6-bioperl
PDF
Php Crash Course - Macq Electronique 2010
PPTX
PHP Basics and Demo HackU
PDF
Developing IT infrastructures with Puppet
PDF
Perl 5.10
ODP
What's new, what's hot in PHP 5.3
PDF
What we can learn from Rebol?
KEY
Perl: Hate it for the Right Reasons
PPTX
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PPTX
Introduction in php part 2
PPT
Training on php by cyber security infotech (csi)
ODP
Mastering Namespaces in PHP
ODP
Advanced Perl Techniques
PPTX
Troubleshooting Puppet
PPTX
Puppet Troubleshooting
Puppet Camp Berlin 2015: The Power of Puppet 4
Puppet Camp Amsterdam 2015: The Power of Puppet 4 (Beginner)
Can you upgrade to Puppet 4.x?
Introduction to Modern Perl
Puppet Camp Duesseldorf 2014: Martin Alfke - Can you upgrade to puppet 4.x?
Bioinformatica 10-11-2011-p6-bioperl
Php Crash Course - Macq Electronique 2010
PHP Basics and Demo HackU
Developing IT infrastructures with Puppet
Perl 5.10
What's new, what's hot in PHP 5.3
What we can learn from Rebol?
Perl: Hate it for the Right Reasons
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
Introduction in php part 2
Training on php by cyber security infotech (csi)
Mastering Namespaces in PHP
Advanced Perl Techniques
Troubleshooting Puppet
Puppet Troubleshooting
Ad

More from Puppet (20)

PPTX
Puppet Community Day: Planning the Future Together
PPTX
The Evolution of Puppet: Key Changes and Modernization Tips
PPTX
Can You Help Me Upgrade to Puppet 8? Tips, Tools & Best Practices for Your Up...
PPTX
Bolt Dynamic Inventory: Making Puppet Easier
PPTX
Customizing Reporting with the Puppet Report Processor
PPTX
Puppet at ConfigMgmtCamp 2025 Sponsor Deck
PPTX
The State of Puppet in 2025: A Presentation from Developer Relations Lead Dav...
PPTX
Let Red be Red and Green be Green: The Automated Workflow Restarter in GitHub...
PDF
Puppet camp2021 testing modules and controlrepo
PPTX
Puppetcamp r10kyaml
PDF
2021 04-15 operational verification (with notes)
PPTX
Puppet camp vscode
PDF
Modules of the twenties
PDF
Applying Roles and Profiles method to compliance code
PPTX
KGI compliance as-code approach
PDF
Enforce compliance policy with model-driven automation
PDF
Keynote: Puppet camp compliance
PPTX
Automating it management with Puppet + ServiceNow
PPTX
Puppet: The best way to harden Windows
PPTX
Simplified Patch Management with Puppet - Oct. 2020
Puppet Community Day: Planning the Future Together
The Evolution of Puppet: Key Changes and Modernization Tips
Can You Help Me Upgrade to Puppet 8? Tips, Tools & Best Practices for Your Up...
Bolt Dynamic Inventory: Making Puppet Easier
Customizing Reporting with the Puppet Report Processor
Puppet at ConfigMgmtCamp 2025 Sponsor Deck
The State of Puppet in 2025: A Presentation from Developer Relations Lead Dav...
Let Red be Red and Green be Green: The Automated Workflow Restarter in GitHub...
Puppet camp2021 testing modules and controlrepo
Puppetcamp r10kyaml
2021 04-15 operational verification (with notes)
Puppet camp vscode
Modules of the twenties
Applying Roles and Profiles method to compliance code
KGI compliance as-code approach
Enforce compliance policy with model-driven automation
Keynote: Puppet camp compliance
Automating it management with Puppet + ServiceNow
Puppet: The best way to harden Windows
Simplified Patch Management with Puppet - Oct. 2020

Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)