SlideShare ist ein Scribd-Unternehmen logo
1 von 65
Migrating to Puppet 4.0
0.27
2.7.x
3.x
3.x future parser
4.x
Puppet 4.0 Language
henrik.lindberg@puppetlabs.com
@hel
notice 1 => 1
notice 1 + 2 => syntax error
notice(1 + 2) => 3
notice 1,2,3 => 1 2 3
notice [1,2,3] => 1 2 3
notice [1,2],3 => 1 2 3
notice 5 in [5] => true
notice (4+1) in [5] => error, not a string
notice 5 in [4+1] => false
notice 5.0 in [5] => false
notice(0xff =~ /5/) => false
notice((0xfe+1) =~/5/) => true
notice { a=>10 } => error, no title
Godzilla on Type
Juggling….
Puppet 4.0
• Language Cleanup
– Sanity, Principle of Least Surprise
– Expressions, Expressions, Expressions
• Features
– Misc enhancements
– Resource Expression Features
– Iteration
– Type System / Optional Typing
– Embedded Puppet Templates (EPP)
– Heredoc
– Data in Modules and Environments
Cleanup
• Language Specification – yes we have one
– https://github.com/puppetlabs/puppet-specifications
• Numbers are Numbers
• No magic to-string for =~ !~ in
• Upper case bare words are Type References
• Empty string is not undef (and thus "thruty")
• Interpolation follows specified rules
• +=, []= removed, no more mutation
Migrating
Signs Your Goldfish is Dead
– Goldfish skin easily cracks
when flexed
– Goldfish is completely
dried out
– Eyes of goldfish are
concave instead of convex
– Pupils of goldfish are gray
– Body parts of the goldfish
are clearly missing
4.0
+ future
3.8
2.7
To 4.x from < 3.8 no parser=future
• First Migrate to latest 3.8.x
– Coming from < 3.0 (released 2012)
• Dynamic Scoping removed
• Address Deprecations
– Switch to Directory Environments
• Legacy Environments removed in 4.x
– Use PE Catalog Preview with same code in two environments
• (demos on youtube)
• Turn on future parser in one to help with migration to 4.x Language
• FOSS users can use similar free catalog compare tools (with more manual work)
– Do changes in backwards compatible way
– Update modules
– Gradually migrate nodes – "future parser" production safe
To 4.x from 3.8 with parser=future
• Relatively painless
– Standup a new 4.x master
• Packaging and paths changed in 4.x
– The "all in one" agent
– Same Ruby everywhere
– New location for config files, hiera data etc.
• Enjoy new PE 2015.3 / 4.3 features
– Application Management
– Data in Modules
Migrating to Puppet 4.0
Language Changes
concat/append/merge/delete 1(6)
• Concatenate Arrays with +
[1,2,3] + [4,5,6] => [1,2,3,4,5,6]
• Merge Hashes with +
{a=>1} + {b=>2} => {a=>1, b=>2}
• Delete with -
[1,2,3] – [2, 3] => [1]
{a=>1, b=>2, c=>3} – [a,c] => {b=>2}
• Append to Array with <<
[1,2,3] << 4 => [1,2,3,4]
[1,2,3] << [4,5,6] => [1,2,3,[4,5,6]]
unfold/splat 2(6)
• Unfold with unary *
$a = [2,3]
$b = [1, *$a, 4] => [1,2,3,4]
• Unfold in case option, selector and call
$a = [1,2,3]
case 1 {
*$a : { # 1 or 2 or 3
}
}
notice *$a => 1,2,3
notice $a => [1,2,3]
substrings 3(6)
• Substring in string
'cd' in "abcde" => true
• Substring with []
"xyzabcdef"[3,3] => "abc"
"xyzabcdef"[3] => "a"
"xyzabcdef"[3,-2] => "abcde"
regexp string/interpolate 4(6)
• Matches with Regexp in String form
$a = "example.com"
$url =~ "http://$a.*"
Error message improvements 5(6)
• Detailed Error Messages
– Semantic validation unless lex or syntax errors
– Outputs position on line
– Can report more than one error
Expression Based Grammar 6(6)
• if, unless, case are expressions
notice if 1 > 2 { true } else { false }
# => false
$a =
case 2 {
1, 2, 3: { yes }
default: { no }
}
# => $a == yes
Resource Expression
Local Defaults
file {
default:
mode => '444',
owner => 'admin';
title:
. . . ;
}
Unfold Hash of attributes
file {
default:
* => $defaults_hash;
'tmp/foo':
mode => '666',
* => $params_hash;
}
Create Resources Equiv. in Puppet
Resource[$type] {
default:
* => $defaults_hash;
$titles:
* => $params_hash;
}
LOOOOOOOPS
• Iterate over:
– Arrays
– Hashes
– Strings
– Integer ranges
• Implemented as functions taking callable code
blocks (lambdas) = open design
• Calls can now be expressed from left to right
using '.' notation
each
• Do something with each element
• Returns LHS
[1,2,3].each |$x| { notice $x }
each([1,2,3]) |$x| { notice $x }
map
• Transform each element
• Returns transformed result
[1,2,3].map |$x| { $x*10 }
=> [10,20,30]
filter
• Produces elements that match
• Returns filtered result
[1,2,3].filter|$x| { $x >= 2 }
=> [2,3]
reduce
• Transforms / reduces many to one
• Feeds seed/previous result into next iteration
• Returns transformed result
[1,2,3].reduce |$result, $x| {
$result + $x
}
=> 6
What do you see?
Shout out the answer….
Next one….
Are you ready?
Two more…
ok?
The Puppet Type System
Cow
Integer
Puppet Types
• Puppet Types are first order objects (they can
be assigned and passed around in variables)
• Uses syntax familiar from Resource – i.e. Class,
File, User, where [ ] applied to the type makes
it more specific – e.g. File['foo']
Example Integer
# All integers
Integer
# All integers >=42
Integer[42]
# All integers >=42 and <=142
Integer[42,142]
Automatic type checking!
define mytype(Integer[80,443] $port){
# port guaranteed to be integer
# and between 80 and 443
# otherwise an error
}
Manual type checking!
define mytype($port) {
assert_type(Integer[80,443], $port) |$expected, $got| {
warn("Bad port $got, expected $expected. Using port 80.")
80
}
}
• Code block called if given does not match
• …do what you want, fail, warn, return default
Operations on Type
• Since a Type is a kind of Pattern…
– Match with =~ and !~
– Match in case expression
• Since Types are defined in a hierarchy:
– Compare types with <, <=, >, >=
# is $x an integer ?
$x =~ Integer
# is $t more specific than Integer
$t = Integer[80, 144]
$t < Integer
Type Hierarchy
Any
|- Scalar
| |- Numeric
| | |- Integer[from, to]
| | |- Float[from, to]
| |
| |- String[from, to]
| | |- Enum[*strings]
| | |- Pattern[*patterns]
| |
| |- Boolean
| |- Regexp[pattern_string]
Type Hierarchy
Any
|- Collection
| |- Array[T]
| | |- Tuple[T*, from, to]
| |
| |- Hash[K, V]
| | |- Struct[{ key => T, ...}]
|
|- Variant[T*]
|- Optional[T]
|
|- Undef
|- Default
|
|- Type[T]
Type Hierarchy
Any
|- CatalogEntry
| |- Resource[type_name, title]
| |- Class[class_name]
|
|- Undef
|- Data
| |- Scalar
| |- Array[Data]
| |- Hash[Scalar, Data]
| |- Undef
EPP
EPP – Templates in Puppet
• Same template markup as ERB
– Logic is Puppet instead of Ruby
AND
• Can be parameterized !
• Use functions
epp(template)
inline_epp(string)
• instead of
template()
inline_template()
Example EPP
$x = 'human'
inline_epp('This is not the <%= $x %> you are looking
for.', { 'x' => 'droid'})
# => 'This is not the droid you are looking for.'
<%- |$x = 'human'| -%>
This is not the <%= $x %> you are looking for.
$x = 'human'
inline_epp('This is not the <%= $x %> you are looking
for.')
# => 'This is not the human you are looking for.'
Heredoc
Puppet Heredoc
• For more detailed control over a block of text
• No, or selected set of escapes
• Interpolation or no interpolation
• Can be syntax checked by parser (JSon in core,
can add plugin language support)
• Control over left margin
Heredoc - Syntax
@( ["]<endtag>["] [:<syntax>] [/<escapes>] )
<text>
[|][-] <endtag>
ENDS-HERE
anything not in <text>
"ENDS-HERE"
with interpolation
:json
syntax check result
/tsrn$L turns on escape
/ turns on all
|
set left margin
-
trim trailing
t tab
s space
r return
n new-line
$ $
L <end of line>
Puppet Heredoc Example
#.........1.........2.........3.........4.........5....
$a = @(END)
This is indented 2 spaces in the source, but produces
a result flush left with the initial 'T'
This line is thus indented 2 spaces.
| END
#.........1.........2.........3.........4.........5....
foo(@(FIRST), @(SECOND))
This is the text for the first heredoc
FIRST
This is the text for the second
SECOND
Ruby API
Ruby API
• 4x Function API
– type checked
– dispatch to impl based on given types
– more powerful
– safer
• Binder
– composable type safe injection
– for plugins and data (e.g. syntax checkers, data
providers)
Summary
• Language Cleanup
• More strict
• New Features
• Better Error Messages
• Iteration
• Type System
• Puppet Templates – EPP
• Heredoc
Enjoy Puppet 4
Links
• github/puppetlabs/puppet-specifications
• http://puppet-on-the-edge.blogspot.com/
• Twitter @hel
• IRC helindbe
Just use PE the next time, ok?

Weitere ähnliche Inhalte

Was ist angesagt?

COSCUP2012: How to write a bash script like the python?
COSCUP2012: How to write a bash script like the python?COSCUP2012: How to write a bash script like the python?
COSCUP2012: How to write a bash script like the python?
Lloyd Huang
 

Was ist angesagt? (20)

Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.
 
Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
 
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
 
Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'
 
BASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationBASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic Interpolation
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!
 
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackU
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
 
Intro to Perl and Bioperl
Intro to Perl and BioperlIntro to Perl and Bioperl
Intro to Perl and Bioperl
 
Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.
 
Bioinformatica p6-bioperl
Bioinformatica p6-bioperlBioinformatica p6-bioperl
Bioinformatica p6-bioperl
 
Bioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekingeBioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekinge
 
Perforce Object and Record Model
Perforce Object and Record Model  Perforce Object and Record Model
Perforce Object and Record Model
 
Puppet Camp DC 2015: Stop Writing Puppet Modules: A Guide to Best Practices i...
Puppet Camp DC 2015: Stop Writing Puppet Modules: A Guide to Best Practices i...Puppet Camp DC 2015: Stop Writing Puppet Modules: A Guide to Best Practices i...
Puppet Camp DC 2015: Stop Writing Puppet Modules: A Guide to Best Practices i...
 
COSCUP2012: How to write a bash script like the python?
COSCUP2012: How to write a bash script like the python?COSCUP2012: How to write a bash script like the python?
COSCUP2012: How to write a bash script like the python?
 

Ähnlich wie Migrating to Puppet 4.0

Slides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersSlides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammers
Giovanni924
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
pooja bhandari
 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
outcast96
 
MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
BUDNET
 

Ähnlich wie Migrating to Puppet 4.0 (20)

Puppet Language 4.0 - PuppetConf 2014
Puppet Language 4.0 - PuppetConf 2014Puppet Language 4.0 - PuppetConf 2014
Puppet Language 4.0 - PuppetConf 2014
 
Rakudo
RakudoRakudo
Rakudo
 
05php
05php05php
05php
 
Slides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammersSlides chapter3part1 ruby-forjavaprogrammers
Slides chapter3part1 ruby-forjavaprogrammers
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
php
phpphp
php
 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
Adventures in Optimization
Adventures in OptimizationAdventures in Optimization
Adventures in Optimization
 
MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Php Lecture Notes
Php Lecture NotesPhp Lecture Notes
Php Lecture Notes
 
Php Intermediate
Php IntermediatePhp Intermediate
Php Intermediate
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
 
Rails by example
Rails by exampleRails by example
Rails by example
 
Ruby quick ref
Ruby quick refRuby quick ref
Ruby quick ref
 

Mehr von Puppet

Puppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepo
Puppet
 
2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)
Puppet
 
Enforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automationEnforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automation
Puppet
 

Mehr von Puppet (20)

Puppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepo
 
Puppetcamp r10kyaml
Puppetcamp r10kyamlPuppetcamp r10kyaml
Puppetcamp r10kyaml
 
2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)
 
Puppet camp vscode
Puppet camp vscodePuppet camp vscode
Puppet camp vscode
 
Modules of the twenties
Modules of the twentiesModules of the twenties
Modules of the twenties
 
Applying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance codeApplying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance code
 
KGI compliance as-code approach
KGI compliance as-code approachKGI compliance as-code approach
KGI compliance as-code approach
 
Enforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automationEnforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automation
 
Keynote: Puppet camp compliance
Keynote: Puppet camp complianceKeynote: Puppet camp compliance
Keynote: Puppet camp compliance
 
Automating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNowAutomating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNow
 
Puppet: The best way to harden Windows
Puppet: The best way to harden WindowsPuppet: The best way to harden Windows
Puppet: The best way to harden Windows
 
Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020
 
Accelerating azure adoption with puppet
Accelerating azure adoption with puppetAccelerating azure adoption with puppet
Accelerating azure adoption with puppet
 
Puppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael PinsonPuppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael Pinson
 
ServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin ReeuwijkServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin Reeuwijk
 
Take control of your dev ops dumping ground
Take control of your  dev ops dumping groundTake control of your  dev ops dumping ground
Take control of your dev ops dumping ground
 
100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy Software100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy Software
 
Puppet User Group
Puppet User GroupPuppet User Group
Puppet User Group
 
Continuous Compliance and DevSecOps
Continuous Compliance and DevSecOpsContinuous Compliance and DevSecOps
Continuous Compliance and DevSecOps
 
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick MaludyThe Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Migrating to Puppet 4.0

  • 2.
  • 5. 3.x
  • 7. 4.x
  • 8.
  • 10. notice 1 => 1 notice 1 + 2 => syntax error notice(1 + 2) => 3 notice 1,2,3 => 1 2 3 notice [1,2,3] => 1 2 3 notice [1,2],3 => 1 2 3 notice 5 in [5] => true notice (4+1) in [5] => error, not a string notice 5 in [4+1] => false notice 5.0 in [5] => false notice(0xff =~ /5/) => false notice((0xfe+1) =~/5/) => true notice { a=>10 } => error, no title
  • 12. Puppet 4.0 • Language Cleanup – Sanity, Principle of Least Surprise – Expressions, Expressions, Expressions • Features – Misc enhancements – Resource Expression Features – Iteration – Type System / Optional Typing – Embedded Puppet Templates (EPP) – Heredoc – Data in Modules and Environments
  • 13. Cleanup • Language Specification – yes we have one – https://github.com/puppetlabs/puppet-specifications • Numbers are Numbers • No magic to-string for =~ !~ in • Upper case bare words are Type References • Empty string is not undef (and thus "thruty") • Interpolation follows specified rules • +=, []= removed, no more mutation
  • 15. Signs Your Goldfish is Dead – Goldfish skin easily cracks when flexed – Goldfish is completely dried out – Eyes of goldfish are concave instead of convex – Pupils of goldfish are gray – Body parts of the goldfish are clearly missing
  • 17. To 4.x from < 3.8 no parser=future • First Migrate to latest 3.8.x – Coming from < 3.0 (released 2012) • Dynamic Scoping removed • Address Deprecations – Switch to Directory Environments • Legacy Environments removed in 4.x – Use PE Catalog Preview with same code in two environments • (demos on youtube) • Turn on future parser in one to help with migration to 4.x Language • FOSS users can use similar free catalog compare tools (with more manual work) – Do changes in backwards compatible way – Update modules – Gradually migrate nodes – "future parser" production safe
  • 18. To 4.x from 3.8 with parser=future • Relatively painless – Standup a new 4.x master • Packaging and paths changed in 4.x – The "all in one" agent – Same Ruby everywhere – New location for config files, hiera data etc. • Enjoy new PE 2015.3 / 4.3 features – Application Management – Data in Modules
  • 21. concat/append/merge/delete 1(6) • Concatenate Arrays with + [1,2,3] + [4,5,6] => [1,2,3,4,5,6] • Merge Hashes with + {a=>1} + {b=>2} => {a=>1, b=>2} • Delete with - [1,2,3] – [2, 3] => [1] {a=>1, b=>2, c=>3} – [a,c] => {b=>2} • Append to Array with << [1,2,3] << 4 => [1,2,3,4] [1,2,3] << [4,5,6] => [1,2,3,[4,5,6]]
  • 22. unfold/splat 2(6) • Unfold with unary * $a = [2,3] $b = [1, *$a, 4] => [1,2,3,4] • Unfold in case option, selector and call $a = [1,2,3] case 1 { *$a : { # 1 or 2 or 3 } } notice *$a => 1,2,3 notice $a => [1,2,3]
  • 23. substrings 3(6) • Substring in string 'cd' in "abcde" => true • Substring with [] "xyzabcdef"[3,3] => "abc" "xyzabcdef"[3] => "a" "xyzabcdef"[3,-2] => "abcde"
  • 24. regexp string/interpolate 4(6) • Matches with Regexp in String form $a = "example.com" $url =~ "http://$a.*"
  • 25. Error message improvements 5(6) • Detailed Error Messages – Semantic validation unless lex or syntax errors – Outputs position on line – Can report more than one error
  • 26. Expression Based Grammar 6(6) • if, unless, case are expressions notice if 1 > 2 { true } else { false } # => false $a = case 2 { 1, 2, 3: { yes } default: { no } } # => $a == yes
  • 28. Local Defaults file { default: mode => '444', owner => 'admin'; title: . . . ; }
  • 29. Unfold Hash of attributes file { default: * => $defaults_hash; 'tmp/foo': mode => '666', * => $params_hash; }
  • 30. Create Resources Equiv. in Puppet Resource[$type] { default: * => $defaults_hash; $titles: * => $params_hash; }
  • 31.
  • 32. LOOOOOOOPS • Iterate over: – Arrays – Hashes – Strings – Integer ranges • Implemented as functions taking callable code blocks (lambdas) = open design • Calls can now be expressed from left to right using '.' notation
  • 33. each • Do something with each element • Returns LHS [1,2,3].each |$x| { notice $x } each([1,2,3]) |$x| { notice $x }
  • 34. map • Transform each element • Returns transformed result [1,2,3].map |$x| { $x*10 } => [10,20,30]
  • 35. filter • Produces elements that match • Returns filtered result [1,2,3].filter|$x| { $x >= 2 } => [2,3]
  • 36. reduce • Transforms / reduces many to one • Feeds seed/previous result into next iteration • Returns transformed result [1,2,3].reduce |$result, $x| { $result + $x } => 6
  • 37. What do you see? Shout out the answer….
  • 38.
  • 40.
  • 42.
  • 43.
  • 44. The Puppet Type System Cow Integer
  • 45. Puppet Types • Puppet Types are first order objects (they can be assigned and passed around in variables) • Uses syntax familiar from Resource – i.e. Class, File, User, where [ ] applied to the type makes it more specific – e.g. File['foo']
  • 46. Example Integer # All integers Integer # All integers >=42 Integer[42] # All integers >=42 and <=142 Integer[42,142]
  • 47. Automatic type checking! define mytype(Integer[80,443] $port){ # port guaranteed to be integer # and between 80 and 443 # otherwise an error }
  • 48. Manual type checking! define mytype($port) { assert_type(Integer[80,443], $port) |$expected, $got| { warn("Bad port $got, expected $expected. Using port 80.") 80 } } • Code block called if given does not match • …do what you want, fail, warn, return default
  • 49. Operations on Type • Since a Type is a kind of Pattern… – Match with =~ and !~ – Match in case expression • Since Types are defined in a hierarchy: – Compare types with <, <=, >, >= # is $x an integer ? $x =~ Integer # is $t more specific than Integer $t = Integer[80, 144] $t < Integer
  • 50. Type Hierarchy Any |- Scalar | |- Numeric | | |- Integer[from, to] | | |- Float[from, to] | | | |- String[from, to] | | |- Enum[*strings] | | |- Pattern[*patterns] | | | |- Boolean | |- Regexp[pattern_string]
  • 51. Type Hierarchy Any |- Collection | |- Array[T] | | |- Tuple[T*, from, to] | | | |- Hash[K, V] | | |- Struct[{ key => T, ...}] | |- Variant[T*] |- Optional[T] | |- Undef |- Default | |- Type[T]
  • 52. Type Hierarchy Any |- CatalogEntry | |- Resource[type_name, title] | |- Class[class_name] | |- Undef |- Data | |- Scalar | |- Array[Data] | |- Hash[Scalar, Data] | |- Undef
  • 53. EPP
  • 54. EPP – Templates in Puppet • Same template markup as ERB – Logic is Puppet instead of Ruby AND • Can be parameterized ! • Use functions epp(template) inline_epp(string) • instead of template() inline_template()
  • 55. Example EPP $x = 'human' inline_epp('This is not the <%= $x %> you are looking for.', { 'x' => 'droid'}) # => 'This is not the droid you are looking for.' <%- |$x = 'human'| -%> This is not the <%= $x %> you are looking for. $x = 'human' inline_epp('This is not the <%= $x %> you are looking for.') # => 'This is not the human you are looking for.'
  • 57. Puppet Heredoc • For more detailed control over a block of text • No, or selected set of escapes • Interpolation or no interpolation • Can be syntax checked by parser (JSon in core, can add plugin language support) • Control over left margin
  • 58. Heredoc - Syntax @( ["]<endtag>["] [:<syntax>] [/<escapes>] ) <text> [|][-] <endtag> ENDS-HERE anything not in <text> "ENDS-HERE" with interpolation :json syntax check result /tsrn$L turns on escape / turns on all | set left margin - trim trailing t tab s space r return n new-line $ $ L <end of line>
  • 59. Puppet Heredoc Example #.........1.........2.........3.........4.........5.... $a = @(END) This is indented 2 spaces in the source, but produces a result flush left with the initial 'T' This line is thus indented 2 spaces. | END #.........1.........2.........3.........4.........5.... foo(@(FIRST), @(SECOND)) This is the text for the first heredoc FIRST This is the text for the second SECOND
  • 61. Ruby API • 4x Function API – type checked – dispatch to impl based on given types – more powerful – safer • Binder – composable type safe injection – for plugins and data (e.g. syntax checkers, data providers)
  • 62. Summary • Language Cleanup • More strict • New Features • Better Error Messages • Iteration • Type System • Puppet Templates – EPP • Heredoc
  • 65. Just use PE the next time, ok?

Hinweis der Redaktion

  1. Let's talk about your Puppet installation… Are you perhaps romancing the state of your configuration management system ? Let's see a show of hands…
  2. How many are on 0.27 still? I am glad that there are none of you that still cook your bowie knife skewed road-kill dinner over an open fire.
  3. How about 2.7 then? Much more inhabitable, but not many modern facilities. And oh, you have to turn down the kerosene lamps when cooking something or you will run out of oxygen…
  4. 3.x versions up to, but not incuding 3.8 ? Now we have a much more robust house. A quaint rural design done in the Brittish tradition with pipes on the outside, and thick lush wall to wall carpets in the bathrooms… that are never lush and never lush and nice to walk on because – well they are always soggy… … but if we walk around the back of the house…
  5. We have been building up the new version in parallel and shipped in with Puppet behind the parser=future feature flag during the Puppet 3.x series. In Puppet 3.5/3.6 is started to be quite decent Since Puppet 3.8 it is also fully supported in Puppet Enterprise.
  6. In Puppet 4.0 the modern section is on par with 3.8.x – and during the 4.x series you will see it being built out. As you can see here, the 3.x part is also renovated and some of the old quirky things removed. A large portion of the older implementation is still there though – and this is the part of Puppet that we we will now start addressing. So, how hard is it to migrate ? Well, it depends on where you are starting, and how much customization and creativity you have applied to your older installed puppet…
  7. Clearly the amount of work depends on well you stayed within "best practices" and how much code you have "cloned, and now unfortunately own". All puppet labs supported modules and most major modules have been updated to work well with 4.x. In this presentation I will present an overview of the changes in the 4.0 Puppet Language and some of its new features. I will also talk about some of the tools you can use to help you migrate. (Picture: House from Lemony Snicket…)
  8. Hi, I am henrik lindberg, and I am here to talk about Puppet 4.0.
  9. It all started with things like these amazing 3.x results
  10. Grrrr ! If you are interested in going WAT Spelunking, Nick Fagerlund has a repo with "Evil Made Manifests"
  11. So, what is in Puppet 4.0 from a language perspective?
  12. So, how do you migrate in practice ? If you do it the wrong way you may kill your goldfish.
  13. (I found this at a serious Pet Shop on-line giving instructions how to deal with goldfish having jumped out of their bowl – which apparently happens quite often). So how do we prevent that…
  14. The way to go is to do this in steps. (I did not include the unsavory 0.27 brownish bowl with algae and floaters …)
  15. Big Bang? Smaller Cymbals? How big is your Polar Bear? The 12000 nodes size like at Spotify, of just a handful… Think about the risk/reward
  16. While it may not rock your socks off – since the next feature have been out in the future parser since it first arrived in 3.4 – it is still one of the biggest new features…
  17. And now for an experiment – Please work with me here, or this will be a perfect lead balloon…
  18. COOKIE !!!!
  19. COW
  20. STRING
  21. INTEGER !!! Alright enough fun and games – I think you know where this is going…
  22. A Type System is about abstraction. And works just like the process we just used to recognize images of things using our brains pattern matching and abstraction capabilities. There was an image of a Cow, and we matched against what we know characterizes a Cow, and we selected the name for it. The fact that it was not a real cow, but a muppet did not distract us – we were simply not confused by the multiple levels of abstraction. If someone had shouted, "fabric and foam rubber arranged to resemble a cow" – that would also have been correct, only at a different level of abstraction. We did this pattern matching in analog way to how the Puppet Type system matches something like the numeric value 42 to the type Integer, an abstraction describing all integral numbers, just like the word Cow is an abstraction of all cows. Type is simply a pattern matcher similar to how a regular expression is a pattern matcher specific to strings.
  23. Lets take a closer look at the Integer type
  24. API for plugin of syntax to be finalizd in Puppet 4.0 – will change slightly due to a namespace conflict in puppetx namespace