SlideShare a Scribd company logo
From Puppet 3 to 4:
Code Changes
A quick survey of the most common
code issues in the field, when
migrating Puppet code
from version three
to four
Gabriel M Schuyler
Professional Services, Puppet, Inc.
@gabe_sky
Introductions
Pro Services at Puppet
Assist in migrations
Dislike over-planning
Me You
Probably in operations ... yes?
Any level of experience
Need a quick heads-up
Hi there, I'm Gabe Schuyler. I work in Professional Services at Puppet, Inc.

I travel all around the world -- training, getting folks started, consulting. Lately I've been doing Puppet 3 to 4 migrations.

I'm in a hurry ... so I don't like analysis paralysis. Look ahead at what you're about to do, but don't go crazy with the what-if.

Show of hands -- who identifies themselves as "operations?" Does anyone still have "devops" on their business card?

For this talk, you don't need to be super-experienced. We're not going to look at anything all that complex.

You need to do things now. You're not doing anything fancy -- you just want some tips before you get started.
Puppet Server
All-In-One Agent packaging
Facter 3
Wait. Why am I upgrading?
There's not a lot of point upgrading something if it doesn't provide any advantage. Here are a few advantages.

The new "puppet server" for the Master vastly improves performance. Our tests say it handles 2.5x the Agents that Ruby-based
can.

"All in one" Agent packaging means no more vying with the system's version of components. For instance, it has Ruby 2.1.

Facter 3 is much faster, and returns structured facts, rather than just strings. These are hashes, and also are more strongly
typed.
Don't panic.
New features are opt-in.
Puppet 3 Agents abide Puppet 4 Masters.
Okay. Where do I start?
Our official docs have enormous lists of changes. You are not affected by most of these. I'm about to tell you what matters.

Things like iteration, or specifying the type of your class parameters are opt-in. Your Puppet 3 code can keep leaving them out.

Since code is compiled on the Master, you can keep using old Agents. They may get a catalog with extra data, but they'll ignore
it.

Okay. Let's get into some of the really simple things you're going to need to look out for in your code.
Numbers are Numbers
file { '/etc/motd':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
}
Warning: Non-string values for the file mode property are
deprecated. It must be a string, either a symbolic mode
like 'o+w,a+r' or an octal representation like '0644' or
'755'.
Error: Parameter mode failed on File[/etc/motd]: The file
mode specification must be a string, not 'Fixnum' at line
1
3
4
Puppet 3 tends to pass values around as strings, so the provider would just incidentally get '0644' passed to it. 

Puppet 4 preserves more about the types of objects. One of those types, is numbers.

The most common case where this difference causes issues is with file resource modes.

Puppet 4 sees an unquoted number as an actual (octal) number.

The provider requires a string. Puppet 3 with future parser will issue a deprecation warning. Puppet 4 will fail because of the
type.

Only undef and false are actually false in Puppet 4.
Some code relies on empty strings to evaluate to false.
Try puppetlabs/stdlib str2bool( ) function.
Booleans
if ( '' ) {
notify { 'An empty string is true in Puppet 4': }
}
if ( str2bool('') == false ) {
notify { 'str2bool() always says an empty string is false': }
}
It used to be Puppet 3 would treat an empty string as false. Now only undefined or an actual boolean false are.

A common example where this causes trouble, is a custom fact that returns an empty string to indicate, generally, "not
applicable"

In their code they would simply evaluate the truth of the variable to decide if they needed to apply its value to something.
Lowercase your Variable Names
Puppet 3 allows variable names to start with capital letters.
Puppet 4 requires they start with lowercase alphabetical letter.
$Pkg_name = 'awesome-server'
package { $Pkg_name:
ensure => installed,
}
Error: Illegal variable name, The given name 'Pkg_name'
does not conform to the naming rule /^((::)?[a-z]
w*)*((::)?[a-z_]w*)$/ at /tmp/variables.pp:1:1
I don't see this one all that much, but it's out there, and will cause your catalog to fail compilation.
A Little More Esoteric
Regexps on Numbers
Class names with hyphens
Unquoted cases
Relative class declaration
ERB variables lacking @
class configure-me {
if ( $::memorysize_mb =~ /^1ddd/ ) {
notify { 'Looks like a small instance size.': }
}
case $::operatingsystem {
centos,redhat: { notify { 'I am RedHat-ish.': } }
debian: { include debian } # configure-me::debian
default: { notify { 'I do not have a hat.': } }
}
}
<%= @my_variable %>
Not so common, but worth mentioning, are a few more Puppet 4 differences. Here's a heads-up on five of them.

Passing things around internally as strings used to mean you could do a regexp on a number. No longer. This if statement would
fail.

(Though it's interesting to note that some facts that look like numbers, may be strings. For instance, version numbers like 6.5.1.)

Make sure you haven't used hyphens in class names. They are no longer allowed. This example class is no longer valid.

Also, the old behavior of an include first searching for a subclass under the current class no longer works. This is a good thing.

Not pictured here, you'll now get a warning (and likely the template generation will misbehave) if you don't have @variable.
Node inheritance no longer works.
Vestiges of Puppet 2 -- Nodes
node 'linux_base' {
include ssh
include selinux
include sudoers
}
node 'linux_exposed' inherits 'linux_base' {
include iptables
}

node 'web001.puppet.com' inherits 'linux_exposed' {
include apache
include apache::mod::php
}
It used to be a common design pattern to create node definitions that served only as templates that others would add on to.

For instance, this example is somewhat common. All Linux nodes inherit a fictitious node called linux_base.

This sometimes resulted in chains of inheritance that composed a node from an aggregation of node definitions.

This is no longer allowed. For an alternative, look at the Roles & Profiles design pattern.
Importing other manifests no longer works.
Vestiges of Puppet 2 -- Import
# site.pp
import nodes/*.pp
# environments/$environment/environment.conf
manifest = nodes
It used to be common that when site.pp got too large, you'd break it into smaller files and have site.pp import those.

Import no longer works.

However, for some time now, the "manifest" setting has been willing to take a whole directory as its setting.

And it defaults to reading the whole "manifests" directory, which on a base install just contains the site.pp file.

You likely won't need to change much, as it will recurse into subdirectories, which is where folks have be storing these already.

You can override where Puppet looks for manifests by changing an environment's "manifest" setting.
Structured facts
Typed facts
Old-style facts
System Gems
Facter 3
os => {
architecture => "x86_64",
family => "RedHat",
hardware => "x86_64",
name => "CentOS",
release => {
full => "7.2.1511",
major => "7",
minor => "2"
}
}
notify { "${::os['family']}": }
notify { "${::osfamily}": }
Facter 3, which is the one that the Puppet 4 installer will give you, is a little fancier than you might be used to.

Structured facts, for instance, are actual hashes of keys and values. To index a sub-item, use normal array indexing notation.

Facter 2 tended to represent facts as strings. Facter 3 is more aware of types. Test some agents with "stringify_facts" set to
false.

Structured facts are handy, but tons of code uses the old Facter 2 built-in facts. For the most part, 3 will return these if asked.

Note that if you have custom facts use Ruby gem/library, you'll need to make sure the new vendored Ruby has them as well.

By the way, Facter 3 is much faster than 2.
puppet parser validate
puppet-lint and plug-ins
zack/catalog_diff
puppetlabs/catalog_preview
Automatic Code Checks
It's valuable to know if Puppet 4 is going to compile your catalog at all, and also that it will compile a similar one to Puppet 3.

The most basic of test -- will it parse -- is easy to check on the command line with `puppet parser validate` .. probably in a for
loop.

One step up is to make sure the basic checklist (quoted modes, booleans) is done. There are puppet-lint plug-ins that will do
this.

Next up is to actually compile catalogs, for actual nodes in your environment. You've got two front-running choices here.

Zack's catalog_diff tool will actually talk to two masters, have them compile catalogs from nodes' last facts, and compare them.

The PuppetLabs catalog_preview tool uses a 3.8 Master, compiling catalogs in two environments where one has parser = future.

Please note. Neither of these tools actually applies a catalog to a node. So, for instance, a broken provider will not be revealed.
And that's all I've got.

Despite enormous lists of "breaking changes" my field experience says only a few of them usually crop up in the real world.

In just a few afternoons, you can get a pretty thorough impression of what it's going to take to migrate your code.

And I think you'll be surprised by how easy it's going to be.

I appreciate your attention, and now I welcome your questions.

More Related Content

What's hot

Computer Science Homework Help
Computer Science Homework HelpComputer Science Homework Help
Computer Science Homework Help
Programming Homework Help
 
Python 3000
Python 3000Python 3000
Python 3000
Bob Chao
 
cs3157-summer06-lab1
cs3157-summer06-lab1cs3157-summer06-lab1
cs3157-summer06-lab1
tutorialsruby
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
amiable_indian
 
Implementing a decorator for thread synchronisation.
Implementing a decorator for thread synchronisation.Implementing a decorator for thread synchronisation.
Implementing a decorator for thread synchronisation.
Graham Dumpleton
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
srinivasanr281952
 
Perl intro
Perl introPerl intro
Perl intro
Swapnesh Singh
 
Your Own Metric System
Your Own Metric SystemYour Own Metric System
Your Own Metric System
Erin Dees
 
Introduction to Python - Training for Kids
Introduction to Python - Training for KidsIntroduction to Python - Training for Kids
Introduction to Python - Training for Kids
Aimee Maree Forsstrom
 
Perl_Part4
Perl_Part4Perl_Part4
Perl_Part4
Frank Booth
 
Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at Work
Erin Dees
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS
charsbar
 
Thnad's Revenge
Thnad's RevengeThnad's Revenge
Thnad's Revenge
Erin Dees
 
Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM Compiler
Erin Dees
 

What's hot (14)

Computer Science Homework Help
Computer Science Homework HelpComputer Science Homework Help
Computer Science Homework Help
 
Python 3000
Python 3000Python 3000
Python 3000
 
cs3157-summer06-lab1
cs3157-summer06-lab1cs3157-summer06-lab1
cs3157-summer06-lab1
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
Implementing a decorator for thread synchronisation.
Implementing a decorator for thread synchronisation.Implementing a decorator for thread synchronisation.
Implementing a decorator for thread synchronisation.
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
Perl intro
Perl introPerl intro
Perl intro
 
Your Own Metric System
Your Own Metric SystemYour Own Metric System
Your Own Metric System
 
Introduction to Python - Training for Kids
Introduction to Python - Training for KidsIntroduction to Python - Training for Kids
Introduction to Python - Training for Kids
 
Perl_Part4
Perl_Part4Perl_Part4
Perl_Part4
 
Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at Work
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS
 
Thnad's Revenge
Thnad's RevengeThnad's Revenge
Thnad's Revenge
 
Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM Compiler
 

Similar to Migrating Puppet 3 to 4 -- Code Changes

10 things you're doing wrong in Talend
10 things you're doing wrong in Talend10 things you're doing wrong in Talend
10 things you're doing wrong in Talend
Datalytyx
 
10 things you're doing wrong in Talend
10 things you're doing wrong in Talend10 things you're doing wrong in Talend
10 things you're doing wrong in Talend
Matthew Schroeder
 
20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-paris20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-paris
Johan De Wit
 
Puppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven DevelopmentPuppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven Development
Puppet
 
Learning puppet chapter 2
Learning puppet chapter 2Learning puppet chapter 2
Learning puppet chapter 2
Vishal Biyani
 
Ot performance webinar
Ot performance webinarOt performance webinar
Ot performance webinar
Suite Solutions
 
Php extensions
Php extensionsPhp extensions
Php extensions
Elizabeth Smith
 
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Alex Balhatchet
 
Introduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlIntroduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable Perl
Alex Balhatchet
 
How to build your own OpenStack distro using Puppet OpenStack
How to build your own OpenStack distro using Puppet OpenStackHow to build your own OpenStack distro using Puppet OpenStack
How to build your own OpenStack distro using Puppet OpenStack
OpenStack
 
Good Coding Practices with JavaScript
Good Coding Practices with JavaScriptGood Coding Practices with JavaScript
Good Coding Practices with JavaScript
🏁 Pierre-Henry Soria 💡
 
Code with style
Code with styleCode with style
Code with style
Clayton Parker
 
Intermediate python
Intermediate pythonIntermediate python
Intermediate python
NaphtaliOchonogor1
 
HPC and HPGPU Cluster Tutorial
HPC and HPGPU Cluster TutorialHPC and HPGPU Cluster Tutorial
HPC and HPGPU Cluster Tutorial
Dirk Hähnel
 
CS225_Prelecture_Notes 2nd
CS225_Prelecture_Notes 2ndCS225_Prelecture_Notes 2nd
CS225_Prelecture_Notes 2nd
Edward Chen
 
Python Interview Questions And Answers
Python Interview Questions And AnswersPython Interview Questions And Answers
Python Interview Questions And Answers
H2Kinfosys
 
INTRODUCTION TO MACHINE LEARNING FOR MATERIALS SCIENCE
INTRODUCTION TO MACHINE LEARNING FOR MATERIALS SCIENCEINTRODUCTION TO MACHINE LEARNING FOR MATERIALS SCIENCE
INTRODUCTION TO MACHINE LEARNING FOR MATERIALS SCIENCE
IPutuAdiPratama
 
Code with Style - PyOhio
Code with Style - PyOhioCode with Style - PyOhio
Code with Style - PyOhio
Clayton Parker
 
Functions in Python Syntax and working .
Functions in Python Syntax and working .Functions in Python Syntax and working .
Functions in Python Syntax and working .
tarunsharmaug23
 
Php extensions
Php extensionsPhp extensions
Php extensions
Elizabeth Smith
 

Similar to Migrating Puppet 3 to 4 -- Code Changes (20)

10 things you're doing wrong in Talend
10 things you're doing wrong in Talend10 things you're doing wrong in Talend
10 things you're doing wrong in Talend
 
10 things you're doing wrong in Talend
10 things you're doing wrong in Talend10 things you're doing wrong in Talend
10 things you're doing wrong in Talend
 
20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-paris20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-paris
 
Puppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven DevelopmentPuppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven Development
 
Learning puppet chapter 2
Learning puppet chapter 2Learning puppet chapter 2
Learning puppet chapter 2
 
Ot performance webinar
Ot performance webinarOt performance webinar
Ot performance webinar
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
 
Introduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlIntroduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable Perl
 
How to build your own OpenStack distro using Puppet OpenStack
How to build your own OpenStack distro using Puppet OpenStackHow to build your own OpenStack distro using Puppet OpenStack
How to build your own OpenStack distro using Puppet OpenStack
 
Good Coding Practices with JavaScript
Good Coding Practices with JavaScriptGood Coding Practices with JavaScript
Good Coding Practices with JavaScript
 
Code with style
Code with styleCode with style
Code with style
 
Intermediate python
Intermediate pythonIntermediate python
Intermediate python
 
HPC and HPGPU Cluster Tutorial
HPC and HPGPU Cluster TutorialHPC and HPGPU Cluster Tutorial
HPC and HPGPU Cluster Tutorial
 
CS225_Prelecture_Notes 2nd
CS225_Prelecture_Notes 2ndCS225_Prelecture_Notes 2nd
CS225_Prelecture_Notes 2nd
 
Python Interview Questions And Answers
Python Interview Questions And AnswersPython Interview Questions And Answers
Python Interview Questions And Answers
 
INTRODUCTION TO MACHINE LEARNING FOR MATERIALS SCIENCE
INTRODUCTION TO MACHINE LEARNING FOR MATERIALS SCIENCEINTRODUCTION TO MACHINE LEARNING FOR MATERIALS SCIENCE
INTRODUCTION TO MACHINE LEARNING FOR MATERIALS SCIENCE
 
Code with Style - PyOhio
Code with Style - PyOhioCode with Style - PyOhio
Code with Style - PyOhio
 
Functions in Python Syntax and working .
Functions in Python Syntax and working .Functions in Python Syntax and working .
Functions in Python Syntax and working .
 
Php extensions
Php extensionsPhp extensions
Php extensions
 

More from Gabriel Schuyler

2024 Kernelcon Attack and Defense of AI.pdf
2024 Kernelcon Attack and Defense of AI.pdf2024 Kernelcon Attack and Defense of AI.pdf
2024 Kernelcon Attack and Defense of AI.pdf
Gabriel Schuyler
 
2023 BSides ATX Trending Attack and Defense.pdf
2023 BSides ATX Trending Attack and Defense.pdf2023 BSides ATX Trending Attack and Defense.pdf
2023 BSides ATX Trending Attack and Defense.pdf
Gabriel Schuyler
 
Trends in Cloud Security Attack & Defense
Trends in Cloud Security Attack & DefenseTrends in Cloud Security Attack & Defense
Trends in Cloud Security Attack & Defense
Gabriel Schuyler
 
Pancakes Con 4 Trends in Cloud Security & Fun Facts about Real Clouds
Pancakes Con 4 Trends in Cloud Security & Fun Facts about Real CloudsPancakes Con 4 Trends in Cloud Security & Fun Facts about Real Clouds
Pancakes Con 4 Trends in Cloud Security & Fun Facts about Real Clouds
Gabriel Schuyler
 
Automating Security Tests in Development with Docker
Automating Security Tests in Development with DockerAutomating Security Tests in Development with Docker
Automating Security Tests in Development with Docker
Gabriel Schuyler
 
2022 GrrCON Shifting Right with Policy as Code.pdf
2022 GrrCON Shifting Right with Policy as Code.pdf2022 GrrCON Shifting Right with Policy as Code.pdf
2022 GrrCON Shifting Right with Policy as Code.pdf
Gabriel Schuyler
 
Texas Cyber Summit 2022: Challenges Securing Cloud-Native.pdf
Texas Cyber Summit 2022: Challenges Securing Cloud-Native.pdfTexas Cyber Summit 2022: Challenges Securing Cloud-Native.pdf
Texas Cyber Summit 2022: Challenges Securing Cloud-Native.pdf
Gabriel Schuyler
 
Dog Days of Devops 2022: Policy as Code
Dog Days of Devops 2022: Policy as CodeDog Days of Devops 2022: Policy as Code
Dog Days of Devops 2022: Policy as Code
Gabriel Schuyler
 
fwd:cloudsec 2022: Shifting right with policy-as-code
fwd:cloudsec 2022: Shifting right with policy-as-codefwd:cloudsec 2022: Shifting right with policy-as-code
fwd:cloudsec 2022: Shifting right with policy-as-code
Gabriel Schuyler
 
Hope 2022: Just Enough RFID Cloning to be Dangerous
Hope 2022: Just Enough RFID Cloning to be DangerousHope 2022: Just Enough RFID Cloning to be Dangerous
Hope 2022: Just Enough RFID Cloning to be Dangerous
Gabriel Schuyler
 
Kernel Con 2022: Securing Cloud Native Workloads
Kernel Con 2022: Securing Cloud Native WorkloadsKernel Con 2022: Securing Cloud Native Workloads
Kernel Con 2022: Securing Cloud Native Workloads
Gabriel Schuyler
 
ShmooCon 2022: RFID Key Cloning for Angry Bikers
ShmooCon 2022: RFID Key Cloning for Angry BikersShmooCon 2022: RFID Key Cloning for Angry Bikers
ShmooCon 2022: RFID Key Cloning for Angry Bikers
Gabriel Schuyler
 
Cybersecurity in 2022
Cybersecurity in 2022Cybersecurity in 2022
Cybersecurity in 2022
Gabriel Schuyler
 
IC3 -- Configuration Management 101
IC3 -- Configuration Management 101IC3 -- Configuration Management 101
IC3 -- Configuration Management 101
Gabriel Schuyler
 

More from Gabriel Schuyler (14)

2024 Kernelcon Attack and Defense of AI.pdf
2024 Kernelcon Attack and Defense of AI.pdf2024 Kernelcon Attack and Defense of AI.pdf
2024 Kernelcon Attack and Defense of AI.pdf
 
2023 BSides ATX Trending Attack and Defense.pdf
2023 BSides ATX Trending Attack and Defense.pdf2023 BSides ATX Trending Attack and Defense.pdf
2023 BSides ATX Trending Attack and Defense.pdf
 
Trends in Cloud Security Attack & Defense
Trends in Cloud Security Attack & DefenseTrends in Cloud Security Attack & Defense
Trends in Cloud Security Attack & Defense
 
Pancakes Con 4 Trends in Cloud Security & Fun Facts about Real Clouds
Pancakes Con 4 Trends in Cloud Security & Fun Facts about Real CloudsPancakes Con 4 Trends in Cloud Security & Fun Facts about Real Clouds
Pancakes Con 4 Trends in Cloud Security & Fun Facts about Real Clouds
 
Automating Security Tests in Development with Docker
Automating Security Tests in Development with DockerAutomating Security Tests in Development with Docker
Automating Security Tests in Development with Docker
 
2022 GrrCON Shifting Right with Policy as Code.pdf
2022 GrrCON Shifting Right with Policy as Code.pdf2022 GrrCON Shifting Right with Policy as Code.pdf
2022 GrrCON Shifting Right with Policy as Code.pdf
 
Texas Cyber Summit 2022: Challenges Securing Cloud-Native.pdf
Texas Cyber Summit 2022: Challenges Securing Cloud-Native.pdfTexas Cyber Summit 2022: Challenges Securing Cloud-Native.pdf
Texas Cyber Summit 2022: Challenges Securing Cloud-Native.pdf
 
Dog Days of Devops 2022: Policy as Code
Dog Days of Devops 2022: Policy as CodeDog Days of Devops 2022: Policy as Code
Dog Days of Devops 2022: Policy as Code
 
fwd:cloudsec 2022: Shifting right with policy-as-code
fwd:cloudsec 2022: Shifting right with policy-as-codefwd:cloudsec 2022: Shifting right with policy-as-code
fwd:cloudsec 2022: Shifting right with policy-as-code
 
Hope 2022: Just Enough RFID Cloning to be Dangerous
Hope 2022: Just Enough RFID Cloning to be DangerousHope 2022: Just Enough RFID Cloning to be Dangerous
Hope 2022: Just Enough RFID Cloning to be Dangerous
 
Kernel Con 2022: Securing Cloud Native Workloads
Kernel Con 2022: Securing Cloud Native WorkloadsKernel Con 2022: Securing Cloud Native Workloads
Kernel Con 2022: Securing Cloud Native Workloads
 
ShmooCon 2022: RFID Key Cloning for Angry Bikers
ShmooCon 2022: RFID Key Cloning for Angry BikersShmooCon 2022: RFID Key Cloning for Angry Bikers
ShmooCon 2022: RFID Key Cloning for Angry Bikers
 
Cybersecurity in 2022
Cybersecurity in 2022Cybersecurity in 2022
Cybersecurity in 2022
 
IC3 -- Configuration Management 101
IC3 -- Configuration Management 101IC3 -- Configuration Management 101
IC3 -- Configuration Management 101
 

Recently uploaded

Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and MoreManyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
narinav14
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
Luigi Fugaro
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
kalichargn70th171
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
Envertis Software Solutions
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
kalichargn70th171
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 

Recently uploaded (20)

Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and MoreManyata Tech Park Bangalore_ Infrastructure, Facilities and More
Manyata Tech Park Bangalore_ Infrastructure, Facilities and More
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
 
What’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete RoadmapWhat’s New in Odoo 17 – A Complete Roadmap
What’s New in Odoo 17 – A Complete Roadmap
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 

Migrating Puppet 3 to 4 -- Code Changes

  • 1. From Puppet 3 to 4: Code Changes A quick survey of the most common code issues in the field, when migrating Puppet code from version three to four Gabriel M Schuyler Professional Services, Puppet, Inc. @gabe_sky Introductions Pro Services at Puppet Assist in migrations Dislike over-planning Me You Probably in operations ... yes? Any level of experience Need a quick heads-up Hi there, I'm Gabe Schuyler. I work in Professional Services at Puppet, Inc. I travel all around the world -- training, getting folks started, consulting. Lately I've been doing Puppet 3 to 4 migrations. I'm in a hurry ... so I don't like analysis paralysis. Look ahead at what you're about to do, but don't go crazy with the what-if. Show of hands -- who identifies themselves as "operations?" Does anyone still have "devops" on their business card? For this talk, you don't need to be super-experienced. We're not going to look at anything all that complex. You need to do things now. You're not doing anything fancy -- you just want some tips before you get started. Puppet Server All-In-One Agent packaging Facter 3 Wait. Why am I upgrading? There's not a lot of point upgrading something if it doesn't provide any advantage. Here are a few advantages. The new "puppet server" for the Master vastly improves performance. Our tests say it handles 2.5x the Agents that Ruby-based can. "All in one" Agent packaging means no more vying with the system's version of components. For instance, it has Ruby 2.1. Facter 3 is much faster, and returns structured facts, rather than just strings. These are hashes, and also are more strongly typed.
  • 2. Don't panic. New features are opt-in. Puppet 3 Agents abide Puppet 4 Masters. Okay. Where do I start? Our official docs have enormous lists of changes. You are not affected by most of these. I'm about to tell you what matters. Things like iteration, or specifying the type of your class parameters are opt-in. Your Puppet 3 code can keep leaving them out. Since code is compiled on the Master, you can keep using old Agents. They may get a catalog with extra data, but they'll ignore it. Okay. Let's get into some of the really simple things you're going to need to look out for in your code. Numbers are Numbers file { '/etc/motd': ensure => file, owner => 'root', group => 'root', mode => '0644', } Warning: Non-string values for the file mode property are deprecated. It must be a string, either a symbolic mode like 'o+w,a+r' or an octal representation like '0644' or '755'. Error: Parameter mode failed on File[/etc/motd]: The file mode specification must be a string, not 'Fixnum' at line 1 3 4 Puppet 3 tends to pass values around as strings, so the provider would just incidentally get '0644' passed to it. Puppet 4 preserves more about the types of objects. One of those types, is numbers. The most common case where this difference causes issues is with file resource modes. Puppet 4 sees an unquoted number as an actual (octal) number. The provider requires a string. Puppet 3 with future parser will issue a deprecation warning. Puppet 4 will fail because of the type. Only undef and false are actually false in Puppet 4. Some code relies on empty strings to evaluate to false. Try puppetlabs/stdlib str2bool( ) function. Booleans if ( '' ) { notify { 'An empty string is true in Puppet 4': } } if ( str2bool('') == false ) { notify { 'str2bool() always says an empty string is false': } } It used to be Puppet 3 would treat an empty string as false. Now only undefined or an actual boolean false are. A common example where this causes trouble, is a custom fact that returns an empty string to indicate, generally, "not applicable" In their code they would simply evaluate the truth of the variable to decide if they needed to apply its value to something.
  • 3. Lowercase your Variable Names Puppet 3 allows variable names to start with capital letters. Puppet 4 requires they start with lowercase alphabetical letter. $Pkg_name = 'awesome-server' package { $Pkg_name: ensure => installed, } Error: Illegal variable name, The given name 'Pkg_name' does not conform to the naming rule /^((::)?[a-z] w*)*((::)?[a-z_]w*)$/ at /tmp/variables.pp:1:1 I don't see this one all that much, but it's out there, and will cause your catalog to fail compilation. A Little More Esoteric Regexps on Numbers Class names with hyphens Unquoted cases Relative class declaration ERB variables lacking @ class configure-me { if ( $::memorysize_mb =~ /^1ddd/ ) { notify { 'Looks like a small instance size.': } } case $::operatingsystem { centos,redhat: { notify { 'I am RedHat-ish.': } } debian: { include debian } # configure-me::debian default: { notify { 'I do not have a hat.': } } } } <%= @my_variable %> Not so common, but worth mentioning, are a few more Puppet 4 differences. Here's a heads-up on five of them. Passing things around internally as strings used to mean you could do a regexp on a number. No longer. This if statement would fail. (Though it's interesting to note that some facts that look like numbers, may be strings. For instance, version numbers like 6.5.1.) Make sure you haven't used hyphens in class names. They are no longer allowed. This example class is no longer valid. Also, the old behavior of an include first searching for a subclass under the current class no longer works. This is a good thing. Not pictured here, you'll now get a warning (and likely the template generation will misbehave) if you don't have @variable. Node inheritance no longer works. Vestiges of Puppet 2 -- Nodes node 'linux_base' { include ssh include selinux include sudoers } node 'linux_exposed' inherits 'linux_base' { include iptables }
 node 'web001.puppet.com' inherits 'linux_exposed' { include apache include apache::mod::php } It used to be a common design pattern to create node definitions that served only as templates that others would add on to. For instance, this example is somewhat common. All Linux nodes inherit a fictitious node called linux_base. This sometimes resulted in chains of inheritance that composed a node from an aggregation of node definitions. This is no longer allowed. For an alternative, look at the Roles & Profiles design pattern.
  • 4. Importing other manifests no longer works. Vestiges of Puppet 2 -- Import # site.pp import nodes/*.pp # environments/$environment/environment.conf manifest = nodes It used to be common that when site.pp got too large, you'd break it into smaller files and have site.pp import those. Import no longer works. However, for some time now, the "manifest" setting has been willing to take a whole directory as its setting. And it defaults to reading the whole "manifests" directory, which on a base install just contains the site.pp file. You likely won't need to change much, as it will recurse into subdirectories, which is where folks have be storing these already. You can override where Puppet looks for manifests by changing an environment's "manifest" setting. Structured facts Typed facts Old-style facts System Gems Facter 3 os => { architecture => "x86_64", family => "RedHat", hardware => "x86_64", name => "CentOS", release => { full => "7.2.1511", major => "7", minor => "2" } } notify { "${::os['family']}": } notify { "${::osfamily}": } Facter 3, which is the one that the Puppet 4 installer will give you, is a little fancier than you might be used to. Structured facts, for instance, are actual hashes of keys and values. To index a sub-item, use normal array indexing notation. Facter 2 tended to represent facts as strings. Facter 3 is more aware of types. Test some agents with "stringify_facts" set to false. Structured facts are handy, but tons of code uses the old Facter 2 built-in facts. For the most part, 3 will return these if asked. Note that if you have custom facts use Ruby gem/library, you'll need to make sure the new vendored Ruby has them as well. By the way, Facter 3 is much faster than 2. puppet parser validate puppet-lint and plug-ins zack/catalog_diff puppetlabs/catalog_preview Automatic Code Checks It's valuable to know if Puppet 4 is going to compile your catalog at all, and also that it will compile a similar one to Puppet 3. The most basic of test -- will it parse -- is easy to check on the command line with `puppet parser validate` .. probably in a for loop. One step up is to make sure the basic checklist (quoted modes, booleans) is done. There are puppet-lint plug-ins that will do this. Next up is to actually compile catalogs, for actual nodes in your environment. You've got two front-running choices here. Zack's catalog_diff tool will actually talk to two masters, have them compile catalogs from nodes' last facts, and compare them. The PuppetLabs catalog_preview tool uses a 3.8 Master, compiling catalogs in two environments where one has parser = future. Please note. Neither of these tools actually applies a catalog to a node. So, for instance, a broken provider will not be revealed.
  • 5. And that's all I've got. Despite enormous lists of "breaking changes" my field experience says only a few of them usually crop up in the real world. In just a few afternoons, you can get a pretty thorough impression of what it's going to take to migrate your code. And I think you'll be surprised by how easy it's going to be. I appreciate your attention, and now I welcome your questions.