SlideShare a Scribd company logo
Puppet 4: The Low WAT-tage
Edition
Nick Fagerlund, Puppet
nickf@puppet.com
@nfagerlund
nfagerlund.net
2
Hi, I’m Nick Fagerlund!!!!
I’ve seen things you people wouldn’t believe
My 2013 talk: https://www.youtube.com/watch?v=aU7vjKYqMUo
My much smarter inspiration: https://www.destroyallsoftware.com/talks/wat
3
Agenda
4
Agenda
1. Fundamental Chaos
2. Slapstick
3. Elegance
5
1. Fundamental Chaos
6
Relative Namespacing
class profile::apache {
include apache
}
7
Relative Namespacing
class profile::apache {
class {'apache':}
}
8
Relative Namespacing
include apache meant…
• <CURRENT NAMESPACE>::apache
• <PARENT OF CURRENT NAMESPACE>::apache
• etc. and so on
• Eventually, ::apache
https://projects.puppetlabs.com/issues/2053
https://tickets.puppetlabs.com/browse/PUP-121
9
Relative Namespacing
class profile::apache {
include ::apache
}
10
Is Truth Beauty, and Beauty Truth?
Facts:
architecture => x86_64
domain => local
facterversion => 2.4.2
fqdn => "treepie.local"
gid => staff
hardwareisa => i386
hardwaremodel => x86_64
hostname => treepie
11
Is Truth Beauty, and Beauty Truth?
if $::is_virtual {
# do something
}
12
Is Truth Beauty, and Beauty Truth?
“false”
13
Is Truth Beauty, and Beauty Truth?
if $::is_virtual == 'true' { ... }
# or:
if str2bool($::is_virtual) { ... }
# with the str2bool() function
from puppetlabs/stdlib
14
Is Truth Beauty, and Beauty Truth?
$interfaces =
lo0,gif0,stf0,en0,en1,en2,p2p0,awdl0,
bridge0,utun0
$macaddress_en0 = 72:00:04:eb:7a:93
...etc.
15
2. Slapstick
16
Data Type Nonsense
$myvar = /^# @.*$/
notice($myvar)
# Error: …Syntax error at
'/' at /root/test.pp:1
17
Data Type Nonsense
$one = 1
# String
$one_times_one = 1*1
# Fixnum
$an_undef = undef
# NilClass
$multi_undefs = [undef, undef]
# Symbol (:undef)
18
Interpolation Shenanigans
notice("Twenty plus eighty is ${20 + 80}.")
# Error: left operand of + is not a number at
/root/test.pp:15
19
Interpolation Shenanigans
notice("Twenty plus eighty is ${'20' + 80}.")
# Notice: Scope(Class[main]): Twenty plus
eighty is 100.
20
Interpolation Shenanigans
• Single bare word:
• ${variable}
• Bare word plus chained function call:
• ${variable.split(‘,’)}
• That’s it. Otherwise it’s an expression.
21
Inconsistent Comparisons
notice( 'eat' == 'EAt' ) # true
notice( 'eat' in 'EAten' ) # false
22
The Great Escape
$greeting = 'How's it going?'
23
The Great Escape
$s32path = 'C:WindowsSystem32'
notice($s32path)
# Error: Unclosed quote after ''
in 'C:WindowsSystem32'
24
The Great Escape
$s32path = 'C:WindowsSystem32'
notice($s32path)
# Notice: Scope(Class[main]):
C:WindowsSystem32
>:c
25
The Great Escape
$gitconfig = @("GITCONFIG"/L)
[user]
name = ${displayname}
email = ${email}
[alias]
lg = "log —pretty=format:’%C(yellow)%h
%C(reset) %s%C(cyan)%cr%C(reset) %C(blue)%an
%C(reset) %C(green)%d%C(reset)’ --graph"
| GITCONFIG
26
The Great Escape
$s32path = @(MYPATH)
C:WindowsSystem32
-MYPATH
notice($s32path)
# Notice: Scope(Class[main]):
C:WindowsSystem32
27
Class Class
class class {
notify {'hey it worked':}
}
include class
# Error: Syntax error at 'class' at
/root/test.pp:5
28
Class Class
class class {
notify {'hey it worked':}
}
include "class"
# Notice: hey it worked
# Notice: /Stage[main]/Class/Notify[hey it
worked]/message: defined 'message' as 'hey it
worked'
29
Class Class
class class {
notify {'hey it worked':}
}
include "class"
# Error: 'class' is not a valid classname
at /Users/nick/Desktop/test.pp:1:7
30
3. Elegance
31
Data Type Annotations
class ntp (
$autoupdate = $ntp::params::autoupdate,
$config = $ntp::params::config,
$config_template = $ntp::params::config_template,
$disable_monitor = $ntp::params::disable_monitor,
$driftfile = $ntp::params::driftfile,
$logfile = $ntp::params::logfile,
$iburst_enable = $ntp::params::iburst_enable,
$keys_enable = $ntp::params::keys_enable,
$keys_file = $ntp::params::keys_file,
$keys_controlkey = $ntp::params::keys_controlkey,
$keys_requestkey = $ntp::params::keys_requestkey,
$keys_trusted = $ntp::params::keys_trusted,
$package_ensure = $ntp::params::package_ensure,
$package_name = $ntp::params::package_name,
$panic = $ntp::params::panic,
$preferred_servers = $ntp::params::preferred_servers,
$restrict = $ntp::params::restrict,
$interfaces = $ntp::params::interfaces,
$servers = $ntp::params::servers,
$service_enable = $ntp::params::service_enable,
$service_ensure = $ntp::params::service_ensure,
$service_manage = $ntp::params::service_manage,
$service_name = $ntp::params::service_name,
$udlc = $ntp::params::udlc
) inherits ntp::params {
...
32
...
validate_absolute_path($config)
validate_string($config_template)
validate_bool($disable_monitor)
validate_absolute_path($driftfile)
if $logfile { validate_absolute_path($logfile) }
validate_bool($iburst_enable)
validate_bool($keys_enable)
validate_re($keys_controlkey, ['^d+$', ''])
validate_re($keys_requestkey, ['^d+$', ''])
validate_array($keys_trusted)
validate_string($package_ensure)
validate_array($package_name)
validate_bool($panic)
validate_array($preferred_servers)
validate_array($restrict)
validate_array($interfaces)
validate_array($servers)
validate_bool($service_enable)
validate_string($service_ensure)
validate_bool($service_manage)
validate_string($service_name)
validate_bool($udlc)
Data Type Annotations
~~~~ 👀 ZOOM AND ENHANCE 👀 ~~~~
class ntp (
$config_template = $ntp::params::config_template,
$disable_monitor = $ntp::params::disable_monitor,
...
) inherits ntp::params {
...
validate_string($config_template)
validate_bool($disable_monitor)
33
Data Type Annotations
class ntp (
Boolean $disable_monitor =
$ntp::params::disable_monitor,
Pattern[/^d+$/] $keys_controlkey =
$ntp::params::keys_controlkey,
Integer $keys_requestkey =
$ntp::params::keys_requestkey,
Array $keys_trusted =
$ntp::params::keys_trusted,
String $package_ensure =
$ntp::params::package_ensure,
34
Iteration
•Old Ruby DSL?
•Do-nothing defined types?
•create_resources function?
35
Data Type Annotations
# in Hiera data:
admin_users:
casey:
uid: '1330'
gid: allstaff
shell: zsh
groups:
- developers
- release
leslie:
uid: '1308'
gid: allstaff
groups:
- prosvc
36
# in Puppet manifest:
class puppet_ops::users::virtual {
create_resources(
'@user',
lookup('admin_users'),
{ # defaults
ensure => present,
purge_ssh_keys => true,
}
)
}
Iteration
$binaries = ['facter', 'hiera', 'mco', ‘puppet',
'puppetserver']
$binaries.each |String $binary| {
file { "/usr/bin/${binary}":
ensure => link,
target => "/opt/puppetlabs/bin/${binary}",
}
}
37
EPP Templates
<%- | Boolean $keys_enable,
String $keys_file,
Array $keys_trusted,
String $keys_requestkey,
String $keys_controlkey
| -%>
<%# Parameter tag ↑ -%>
<%# Non-printing tag ↓ -%>
<% if $keys_enable { -%>
<%# Expression-printing tag ↓ -%>
keys <%= $keys_file %>
38
<% unless $keys_trusted =~ Array[Data,0,0]
{ -%>
trustedkey <%= $keys_trusted.join(' ') %>
<% } -%>
<% if $keys_requestkey =~ String[1] { -%>
requestkey <%= $keys_requestkey %>
<% } -%>
<% if $keys_controlkey =~ String[1] { -%>
controlkey <%= $keys_controlkey %>
<% } -%>
<% } -%>
Thanks
39
Questions?
nickf@puppet.com
@nfagerlund
nfagerlund.net
40
PuppetConf 2016: Puppet 4.x: The Low WAT-tage Edition – Nick Fagerlund, Puppet

More Related Content

PDF
PuppetConf 2016: Puppet on Windows – Nicolas Corrarello, Puppet
PDF
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
PDF
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PDF
PuppetConf 2016: Nano Server, Puppet, and DSC
PDF
Final opensource record 2019
PDF
PM : code faster
PPTX
How to do everything with PowerShell
PDF
Php through the eyes of a hoster phpbnl11
PuppetConf 2016: Puppet on Windows – Nicolas Corrarello, Puppet
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PuppetConf 2016: Nano Server, Puppet, and DSC
Final opensource record 2019
PM : code faster
How to do everything with PowerShell
Php through the eyes of a hoster phpbnl11

What's hot (20)

PPTX
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
PPTX
DNN Upgrades Made Simple (DNN Summit 2019)
PPTX
C++ for the Web
PPTX
ABCs of docker
PDF
Everything as a code
PDF
Puppet evolutions
PPT
Why and How Powershell will rule the Command Line - Barcamp LA 4
PDF
Metasploit magic the dark coners of the framework
PPT
Write book in markdown
PPT
Migration from ASP to ASP.NET
PDF
Lviv 2013 d7 vs d8
PDF
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
PDF
Continuous Delivery: The Next Frontier
PPTX
Installaling Puppet Master and Agent
PPTX
Drupal, Memcache and Solr on Windows
PDF
Vagrant + Rouster at salesforce.com - PuppetConf 2013
ODP
PHP: The Beginning and the Zend
PDF
How to deploy node to production
PDF
Dependencies Managers in C/C++. Using stdcpp 2014
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
DNN Upgrades Made Simple (DNN Summit 2019)
C++ for the Web
ABCs of docker
Everything as a code
Puppet evolutions
Why and How Powershell will rule the Command Line - Barcamp LA 4
Metasploit magic the dark coners of the framework
Write book in markdown
Migration from ASP to ASP.NET
Lviv 2013 d7 vs d8
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Continuous Delivery: The Next Frontier
Installaling Puppet Master and Agent
Drupal, Memcache and Solr on Windows
Vagrant + Rouster at salesforce.com - PuppetConf 2013
PHP: The Beginning and the Zend
How to deploy node to production
Dependencies Managers in C/C++. Using stdcpp 2014
Ad

Viewers also liked (17)

PDF
PuppetConf 2016: Testing and Delivering Puppet – Michael Stahnke, Puppet
PDF
PuppetConf 2016: Easily Manage Software on Windows with Chocolatey – Rob Reyn...
PDF
PuppetConf 2016: Collaboration and Empowerment: Driving Change in Infrastruct...
PDF
Puppet at GitHub
PDF
Configuration Changes Don't Have to be Scary: Testing with containers
PDF
Plugging Chocolatey into your Puppet Infrastructure PuppetConf2014
PPTX
Introducion to Puppet Enterprise
PDF
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
PPTX
Canadian Cyber Cecurity
PDF
PuppetConf 2016: Best Practices for Puppet in the Cloud – Randall Hunt, Amazo...
PDF
PuppetConf 2016: The Long, Twisty Road to Automation: Implementing Puppet at ...
PDF
Pro Puppet
PDF
PuppetConf 2016: High Availability for Puppet – Russ Mull & Zack Smith, Puppet
PDF
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PDF
PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...
PDF
PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...
PPTX
Introduction to Puppet Enterprise
PuppetConf 2016: Testing and Delivering Puppet – Michael Stahnke, Puppet
PuppetConf 2016: Easily Manage Software on Windows with Chocolatey – Rob Reyn...
PuppetConf 2016: Collaboration and Empowerment: Driving Change in Infrastruct...
Puppet at GitHub
Configuration Changes Don't Have to be Scary: Testing with containers
Plugging Chocolatey into your Puppet Infrastructure PuppetConf2014
Introducion to Puppet Enterprise
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
Canadian Cyber Cecurity
PuppetConf 2016: Best Practices for Puppet in the Cloud – Randall Hunt, Amazo...
PuppetConf 2016: The Long, Twisty Road to Automation: Implementing Puppet at ...
Pro Puppet
PuppetConf 2016: High Availability for Puppet – Russ Mull & Zack Smith, Puppet
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...
PuppetConf 2016: Puppet and vRealize Automation: The Next Generation – Ganesh...
Introduction to Puppet Enterprise
Ad

Similar to PuppetConf 2016: Puppet 4.x: The Low WAT-tage Edition – Nick Fagerlund, Puppet (20)

PDF
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
PDF
Chef for beginners module 2
PPT
Drush. Why should it be used?
PDF
Test-Driven Puppet Development - PuppetConf 2014
PDF
Ext 0523
PDF
Writing your own augeasproviders
PDF
David Convent - Theme It Yourself
PPTX
Troubleshooting Puppet
PPTX
Puppet Troubleshooting
PDF
Intro to-puppet
PDF
Writing and Publishing Puppet Modules - PuppetConf 2014
PDF
Puppet Design Patterns - PuppetConf
PPT
Learn flask in 90mins
PDF
Growing pains - PosKeyErrors and other malaises
PDF
Containerize spring boot application with docker
PDF
PuppetConf 2016: Deconfiguration Management: Making Puppet Clean Up Its Own M...
PDF
Auto-loading of Drupal CCK Nodes
PDF
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
PDF
Zero Downtime Deployment with Ansible
ODP
Puppet Node Classifiers Talk - Patrick Buckley
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Chef for beginners module 2
Drush. Why should it be used?
Test-Driven Puppet Development - PuppetConf 2014
Ext 0523
Writing your own augeasproviders
David Convent - Theme It Yourself
Troubleshooting Puppet
Puppet Troubleshooting
Intro to-puppet
Writing and Publishing Puppet Modules - PuppetConf 2014
Puppet Design Patterns - PuppetConf
Learn flask in 90mins
Growing pains - PosKeyErrors and other malaises
Containerize spring boot application with docker
PuppetConf 2016: Deconfiguration Management: Making Puppet Clean Up Its Own M...
Auto-loading of Drupal CCK Nodes
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
Zero Downtime Deployment with Ansible
Puppet Node Classifiers Talk - Patrick Buckley

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

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Approach and Philosophy of On baking technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Cloud computing and distributed systems.
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation theory and applications.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
Teaching material agriculture food technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
“AI and Expert System Decision Support & Business Intelligence Systems”
Advanced methodologies resolving dimensionality complications for autism neur...
Approach and Philosophy of On baking technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Reach Out and Touch Someone: Haptics and Empathic Computing
Chapter 3 Spatial Domain Image Processing.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Building Integrated photovoltaic BIPV_UPV.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Cloud computing and distributed systems.
Spectral efficient network and resource selection model in 5G networks
Encapsulation theory and applications.pdf
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Teaching material agriculture food technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

PuppetConf 2016: Puppet 4.x: The Low WAT-tage Edition – Nick Fagerlund, Puppet

  • 1. Puppet 4: The Low WAT-tage Edition Nick Fagerlund, Puppet
  • 3. I’ve seen things you people wouldn’t believe My 2013 talk: https://www.youtube.com/watch?v=aU7vjKYqMUo My much smarter inspiration: https://www.destroyallsoftware.com/talks/wat 3
  • 5. Agenda 1. Fundamental Chaos 2. Slapstick 3. Elegance 5
  • 9. Relative Namespacing include apache meant… • <CURRENT NAMESPACE>::apache • <PARENT OF CURRENT NAMESPACE>::apache • etc. and so on • Eventually, ::apache https://projects.puppetlabs.com/issues/2053 https://tickets.puppetlabs.com/browse/PUP-121 9
  • 11. Is Truth Beauty, and Beauty Truth? Facts: architecture => x86_64 domain => local facterversion => 2.4.2 fqdn => "treepie.local" gid => staff hardwareisa => i386 hardwaremodel => x86_64 hostname => treepie 11
  • 12. Is Truth Beauty, and Beauty Truth? if $::is_virtual { # do something } 12
  • 13. Is Truth Beauty, and Beauty Truth? “false” 13
  • 14. Is Truth Beauty, and Beauty Truth? if $::is_virtual == 'true' { ... } # or: if str2bool($::is_virtual) { ... } # with the str2bool() function from puppetlabs/stdlib 14
  • 15. Is Truth Beauty, and Beauty Truth? $interfaces = lo0,gif0,stf0,en0,en1,en2,p2p0,awdl0, bridge0,utun0 $macaddress_en0 = 72:00:04:eb:7a:93 ...etc. 15
  • 17. Data Type Nonsense $myvar = /^# @.*$/ notice($myvar) # Error: …Syntax error at '/' at /root/test.pp:1 17
  • 18. Data Type Nonsense $one = 1 # String $one_times_one = 1*1 # Fixnum $an_undef = undef # NilClass $multi_undefs = [undef, undef] # Symbol (:undef) 18
  • 19. Interpolation Shenanigans notice("Twenty plus eighty is ${20 + 80}.") # Error: left operand of + is not a number at /root/test.pp:15 19
  • 20. Interpolation Shenanigans notice("Twenty plus eighty is ${'20' + 80}.") # Notice: Scope(Class[main]): Twenty plus eighty is 100. 20
  • 21. Interpolation Shenanigans • Single bare word: • ${variable} • Bare word plus chained function call: • ${variable.split(‘,’)} • That’s it. Otherwise it’s an expression. 21
  • 22. Inconsistent Comparisons notice( 'eat' == 'EAt' ) # true notice( 'eat' in 'EAten' ) # false 22
  • 23. The Great Escape $greeting = 'How's it going?' 23
  • 24. The Great Escape $s32path = 'C:WindowsSystem32' notice($s32path) # Error: Unclosed quote after '' in 'C:WindowsSystem32' 24
  • 25. The Great Escape $s32path = 'C:WindowsSystem32' notice($s32path) # Notice: Scope(Class[main]): C:WindowsSystem32 >:c 25
  • 26. The Great Escape $gitconfig = @("GITCONFIG"/L) [user] name = ${displayname} email = ${email} [alias] lg = "log —pretty=format:’%C(yellow)%h %C(reset) %s%C(cyan)%cr%C(reset) %C(blue)%an %C(reset) %C(green)%d%C(reset)’ --graph" | GITCONFIG 26
  • 27. The Great Escape $s32path = @(MYPATH) C:WindowsSystem32 -MYPATH notice($s32path) # Notice: Scope(Class[main]): C:WindowsSystem32 27
  • 28. Class Class class class { notify {'hey it worked':} } include class # Error: Syntax error at 'class' at /root/test.pp:5 28
  • 29. Class Class class class { notify {'hey it worked':} } include "class" # Notice: hey it worked # Notice: /Stage[main]/Class/Notify[hey it worked]/message: defined 'message' as 'hey it worked' 29
  • 30. Class Class class class { notify {'hey it worked':} } include "class" # Error: 'class' is not a valid classname at /Users/nick/Desktop/test.pp:1:7 30
  • 32. Data Type Annotations class ntp ( $autoupdate = $ntp::params::autoupdate, $config = $ntp::params::config, $config_template = $ntp::params::config_template, $disable_monitor = $ntp::params::disable_monitor, $driftfile = $ntp::params::driftfile, $logfile = $ntp::params::logfile, $iburst_enable = $ntp::params::iburst_enable, $keys_enable = $ntp::params::keys_enable, $keys_file = $ntp::params::keys_file, $keys_controlkey = $ntp::params::keys_controlkey, $keys_requestkey = $ntp::params::keys_requestkey, $keys_trusted = $ntp::params::keys_trusted, $package_ensure = $ntp::params::package_ensure, $package_name = $ntp::params::package_name, $panic = $ntp::params::panic, $preferred_servers = $ntp::params::preferred_servers, $restrict = $ntp::params::restrict, $interfaces = $ntp::params::interfaces, $servers = $ntp::params::servers, $service_enable = $ntp::params::service_enable, $service_ensure = $ntp::params::service_ensure, $service_manage = $ntp::params::service_manage, $service_name = $ntp::params::service_name, $udlc = $ntp::params::udlc ) inherits ntp::params { ... 32 ... validate_absolute_path($config) validate_string($config_template) validate_bool($disable_monitor) validate_absolute_path($driftfile) if $logfile { validate_absolute_path($logfile) } validate_bool($iburst_enable) validate_bool($keys_enable) validate_re($keys_controlkey, ['^d+$', '']) validate_re($keys_requestkey, ['^d+$', '']) validate_array($keys_trusted) validate_string($package_ensure) validate_array($package_name) validate_bool($panic) validate_array($preferred_servers) validate_array($restrict) validate_array($interfaces) validate_array($servers) validate_bool($service_enable) validate_string($service_ensure) validate_bool($service_manage) validate_string($service_name) validate_bool($udlc)
  • 33. Data Type Annotations ~~~~ 👀 ZOOM AND ENHANCE 👀 ~~~~ class ntp ( $config_template = $ntp::params::config_template, $disable_monitor = $ntp::params::disable_monitor, ... ) inherits ntp::params { ... validate_string($config_template) validate_bool($disable_monitor) 33
  • 34. Data Type Annotations class ntp ( Boolean $disable_monitor = $ntp::params::disable_monitor, Pattern[/^d+$/] $keys_controlkey = $ntp::params::keys_controlkey, Integer $keys_requestkey = $ntp::params::keys_requestkey, Array $keys_trusted = $ntp::params::keys_trusted, String $package_ensure = $ntp::params::package_ensure, 34
  • 35. Iteration •Old Ruby DSL? •Do-nothing defined types? •create_resources function? 35
  • 36. Data Type Annotations # in Hiera data: admin_users: casey: uid: '1330' gid: allstaff shell: zsh groups: - developers - release leslie: uid: '1308' gid: allstaff groups: - prosvc 36 # in Puppet manifest: class puppet_ops::users::virtual { create_resources( '@user', lookup('admin_users'), { # defaults ensure => present, purge_ssh_keys => true, } ) }
  • 37. Iteration $binaries = ['facter', 'hiera', 'mco', ‘puppet', 'puppetserver'] $binaries.each |String $binary| { file { "/usr/bin/${binary}": ensure => link, target => "/opt/puppetlabs/bin/${binary}", } } 37
  • 38. EPP Templates <%- | Boolean $keys_enable, String $keys_file, Array $keys_trusted, String $keys_requestkey, String $keys_controlkey | -%> <%# Parameter tag ↑ -%> <%# Non-printing tag ↓ -%> <% if $keys_enable { -%> <%# Expression-printing tag ↓ -%> keys <%= $keys_file %> 38 <% unless $keys_trusted =~ Array[Data,0,0] { -%> trustedkey <%= $keys_trusted.join(' ') %> <% } -%> <% if $keys_requestkey =~ String[1] { -%> requestkey <%= $keys_requestkey %> <% } -%> <% if $keys_controlkey =~ String[1] { -%> controlkey <%= $keys_controlkey %> <% } -%> <% } -%>