SlideShare una empresa de Scribd logo
1 de 67
Descargar para leer sin conexión
Yamata 
no 
Orochi
Puppet 
Language 
4.0 
henrik.lindberg@puppetlabs.com
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
Puppet 
4.0 
• Language 
Cleanup 
– Sanity, 
Principle 
of 
Least 
Surprise 
– Expressions, 
Expressions, 
Expressions 
• Features 
– Misc 
enhancements 
– Resource 
Expression 
Features 
– IteraGon 
– Type 
System 
/ 
OpGonal 
Typing 
– Embedded 
Puppet 
Templates 
(EPP) 
– Heredoc
Cleanup 
• Language 
SpecificaGon 
– 
yes 
we 
have 
one 
– hQps://github.com/puppetlabs/puppet-­‐specificaGons 
• Numbers 
are 
Numbers 
• No 
magic 
to-­‐string 
for 
=~ !~ in 
• Upper 
case 
bare 
words 
are 
Type 
References 
• Empty 
string 
is 
not 
undef 
(and 
thus 
"thruty") 
• InterpolaGon 
follows 
specified 
rules 
• +=, 
[]= 
removed, 
no 
more 
mutaGon
Misc 
new 
features 
1(7) 
• 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}
Misc 
new 
features 
2(7) 
• Append 
to 
Array 
with 
<< 
[1,2,3] << 4 => [1,2,3,4] 
[1,2,3] << [4,5,6] => [1,2,3,[4,5,6]]
Misc 
new 
features 
3(7) 
• Unfold 
with 
unary 
* 
$a = [2,3] 
$b = [1, *$a, 4] => [1,2,3,4] 
• Unfold 
in 
case 
opGon, 
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]
Misc 
new 
features 
4(7) 
• Substring 
in 
string 
'cd' in "abcde" => true 
• Substring 
with 
[] 
"xyzabcdef"[3,3] => "abc" 
"xyzabcdef"[3] => "a" 
"xyzabcdef"[3,-2] => "abcde"
Misc 
new 
features 
5(7) 
• Matches 
with 
Regexp 
in 
String 
form 
$a = "example.com" 
$url =~ "http://$a.*"
Misc 
new 
features 
6(7) 
• Detailed 
Error 
Messages 
– SemanGc 
validaGon 
unless 
lex 
or 
syntax 
errors 
– Outputs 
posiGon 
on 
line 
– Can 
report 
more 
than 
one 
error
Expression 
Based 
Grammar 
6(7) 
• 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 
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 
funcGons 
taking 
callable 
code 
blocks 
(lambdas) 
= 
open 
design 
• Calls 
can 
now 
be 
expressed 
from 
leh 
to 
right 
using 
'.' 
notaGon
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 
iteraGon 
• Returns 
transformed 
result 
[1,2,3].reduce |$result, $x| { 
$result + $x 
} 
=> 6
And 
more
E-­‐I-­‐E-­‐I-­‐O
E-­‐I-­‐E-­‐I-­‐O
E-­‐I-­‐E-­‐I-­‐O
E-­‐I-­‐E-­‐I-­‐O
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]
AutomaGc 
type 
checking! 
define mytype(Integer[80,443] $port){ 
# port guaranteed to be integer 
# and between 80 and 443 
# otherwise an error 
}
More 
advanced 
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
OperaGons 
on 
Type 
• Since 
a 
Type 
is 
a 
kind 
of 
PaQern… 
– 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 
funcGons 
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.') 
# => 'This is not the human you are looking for.' 
$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.
Heredoc
Puppet 
Heredoc 
• For 
more 
detailed 
control 
over 
a 
block 
of 
text 
• No, 
or 
selected 
set 
of 
escapes 
• InterpolaGon 
or 
no 
interpolaGon 
• Can 
be 
syntax 
checked 
by 
parser 
(JSon 
in 
core, 
can 
add 
plugin 
language 
support) 
• Control 
over 
leh 
margin
Heredoc 
-­‐ 
Syntax 
ENDS-­‐HERE 
anything 
not 
in 
<text> 
"ENDS-­‐HERE" 
with 
interpola:on 
:json 
syntax 
check 
result 
/tsrn$L 
turns 
on 
escape 
/ 
turns 
on 
all 
@( ["]<endtag>["] [:<syntax>] [/<escapes>] ) 
<text> 
[|][-] <endtag> 
| 
set 
le= 
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 
FuncGon 
API 
– type 
checked 
– dispatch 
to 
impl 
based 
on 
given 
types 
– more 
powerful 
– safer 
• Binder 
– composable 
type 
safe 
injecGon 
– for 
plugins 
and 
data 
(e.g. 
syntax 
checkers)
Summary 
• Language 
Cleanup 
• More 
strict 
• New 
Features 
• BeQer 
Error 
Messages 
• IteraGon 
• Type 
System 
• Puppet 
Templates 
– 
EPP 
• Heredoc
In 
pracGce 
• Run 
now 
with 
–parser 
future 
• Fix 
deprecaGons 
and 
issues 
• Make 
backwards 
compaGble 
changes 
and 
conGnue 
in 
producGon 
on 
3x 
• Test 
carefully 
and 
conGnue 
running 
on 
what 
will 
be 
Puppet 
4.0 
• 4.0 
expected 
release 
before 
end 
of 
the 
year
Links 
• github/puppetlabs/puppet-­‐specificaGons 
• hQp://puppet-­‐on-­‐the-­‐edge.blogspot.com/ 
• TwiQer 
@hel 
• IRC 
helindbe

Más contenido relacionado

La actualidad más candente

Python Usage (5-minute-summary)
Python Usage (5-minute-summary)Python Usage (5-minute-summary)
Python Usage (5-minute-summary)Ohgyun Ahn
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonUC San Diego
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fuclimatewarrior
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2RajKumar Rampelli
 
Functions in python
Functions in pythonFunctions in python
Functions in pythonIlian Iliev
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP StringsAhmed Swilam
 
Declare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) ServicesDeclare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) ServicesEelco Visser
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programaciónSoftware Guru
 
PHP Functions & Arrays
PHP Functions & ArraysPHP Functions & Arrays
PHP Functions & ArraysHenry Osborne
 
Python Puzzlers - 2016 Edition
Python Puzzlers - 2016 EditionPython Puzzlers - 2016 Edition
Python Puzzlers - 2016 EditionNandan Sawant
 
Nik Graf - Get started with Reason and ReasonReact
Nik Graf - Get started with Reason and ReasonReactNik Graf - Get started with Reason and ReasonReact
Nik Graf - Get started with Reason and ReasonReactOdessaJS Conf
 
Class 4 - PHP Arrays
Class 4 - PHP ArraysClass 4 - PHP Arrays
Class 4 - PHP ArraysAhmed Swilam
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type Systemabrummett
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanWei-Yuan Chang
 

La actualidad más candente (20)

Unit vii wp ppt
Unit vii wp pptUnit vii wp ppt
Unit vii wp ppt
 
Python Usage (5-minute-summary)
Python Usage (5-minute-summary)Python Usage (5-minute-summary)
Python Usage (5-minute-summary)
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
 
Declare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) ServicesDeclare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) Services
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
 
Begin with Python
Begin with PythonBegin with Python
Begin with Python
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
 
PHP Functions & Arrays
PHP Functions & ArraysPHP Functions & Arrays
PHP Functions & Arrays
 
Python Puzzlers - 2016 Edition
Python Puzzlers - 2016 EditionPython Puzzlers - 2016 Edition
Python Puzzlers - 2016 Edition
 
Nik Graf - Get started with Reason and ReasonReact
Nik Graf - Get started with Reason and ReasonReactNik Graf - Get started with Reason and ReasonReact
Nik Graf - Get started with Reason and ReasonReact
 
1 the ruby way
1   the ruby way1   the ruby way
1 the ruby way
 
Class 4 - PHP Arrays
Class 4 - PHP ArraysClass 4 - PHP Arrays
Class 4 - PHP Arrays
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
 
Perl_Tutorial_v1
Perl_Tutorial_v1Perl_Tutorial_v1
Perl_Tutorial_v1
 
Groovy unleashed
Groovy unleashed Groovy unleashed
Groovy unleashed
 

Destacado

Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...
Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...
Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...Puppet
 
To the Future! - Goals for Puppet 4 - PuppetConf 2014
To the Future! - Goals for Puppet 4 - PuppetConf 2014To the Future! - Goals for Puppet 4 - PuppetConf 2014
To the Future! - Goals for Puppet 4 - PuppetConf 2014Puppet
 
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014Puppet
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Puppet
 
The Puppet Master on the JVM - PuppetConf 2014
The Puppet Master on the JVM - PuppetConf 2014The Puppet Master on the JVM - PuppetConf 2014
The Puppet Master on the JVM - PuppetConf 2014Puppet
 
Killer R10K Workflow - PuppetConf 2014
Killer R10K Workflow - PuppetConf 2014Killer R10K Workflow - PuppetConf 2014
Killer R10K Workflow - PuppetConf 2014Puppet
 
Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014Puppet
 
Introduction to Puppet Enterprise 2016.2
Introduction to Puppet Enterprise 2016.2Introduction to Puppet Enterprise 2016.2
Introduction to Puppet Enterprise 2016.2Puppet
 
PuppetConf 2016: The Truth, Nothing but the Truth: Why Type Systems are Impor...
PuppetConf 2016: The Truth, Nothing but the Truth: Why Type Systems are Impor...PuppetConf 2016: The Truth, Nothing but the Truth: Why Type Systems are Impor...
PuppetConf 2016: The Truth, Nothing but the Truth: Why Type Systems are Impor...Puppet
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0Puppet
 
External Data in Puppet 4
External Data in Puppet 4External Data in Puppet 4
External Data in Puppet 4ripienaar
 

Destacado (12)

Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...
Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...
Luke Kanies Keynote: Nearly a Decade of Puppet: What We've Learned and Where ...
 
To the Future! - Goals for Puppet 4 - PuppetConf 2014
To the Future! - Goals for Puppet 4 - PuppetConf 2014To the Future! - Goals for Puppet 4 - PuppetConf 2014
To the Future! - Goals for Puppet 4 - PuppetConf 2014
 
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
 
Puppet evolutions
Puppet evolutionsPuppet evolutions
Puppet evolutions
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
 
The Puppet Master on the JVM - PuppetConf 2014
The Puppet Master on the JVM - PuppetConf 2014The Puppet Master on the JVM - PuppetConf 2014
The Puppet Master on the JVM - PuppetConf 2014
 
Killer R10K Workflow - PuppetConf 2014
Killer R10K Workflow - PuppetConf 2014Killer R10K Workflow - PuppetConf 2014
Killer R10K Workflow - PuppetConf 2014
 
Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014
 
Introduction to Puppet Enterprise 2016.2
Introduction to Puppet Enterprise 2016.2Introduction to Puppet Enterprise 2016.2
Introduction to Puppet Enterprise 2016.2
 
PuppetConf 2016: The Truth, Nothing but the Truth: Why Type Systems are Impor...
PuppetConf 2016: The Truth, Nothing but the Truth: Why Type Systems are Impor...PuppetConf 2016: The Truth, Nothing but the Truth: Why Type Systems are Impor...
PuppetConf 2016: The Truth, Nothing but the Truth: Why Type Systems are Impor...
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0
 
External Data in Puppet 4
External Data in Puppet 4External Data in Puppet 4
External Data in Puppet 4
 

Similar a Yamata no Orochi Puppet Language 4.0 changes optimize expressiveness and type safety

Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionarySoba Arjun
 
Functional programming in ruby
Functional programming in rubyFunctional programming in ruby
Functional programming in rubyKoen Handekyn
 
Data Pipelines in Swift
Data Pipelines in SwiftData Pipelines in Swift
Data Pipelines in SwiftJason Larsen
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangSean Cribbs
 
Pre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPaweł Dawczak
 
Architecting Scalable Platforms in Erlang/OTP | Hamidreza Soleimani | Diginex...
Architecting Scalable Platforms in Erlang/OTP | Hamidreza Soleimani | Diginex...Architecting Scalable Platforms in Erlang/OTP | Hamidreza Soleimani | Diginex...
Architecting Scalable Platforms in Erlang/OTP | Hamidreza Soleimani | Diginex...Hamidreza Soleimani
 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfoutcast96
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potterdistributed matters
 
Useful javascript
Useful javascriptUseful javascript
Useful javascriptLei Kang
 
TDC2016SP - Trilha Programação Funcional
TDC2016SP - Trilha Programação FuncionalTDC2016SP - Trilha Programação Funcional
TDC2016SP - Trilha Programação Funcionaltdc-globalcode
 
Python language data types
Python language data typesPython language data types
Python language data typesHarry Potter
 
Python language data types
Python language data typesPython language data types
Python language data typesHoang Nguyen
 
Python language data types
Python language data typesPython language data types
Python language data typesFraboni Ec
 
Python language data types
Python language data typesPython language data types
Python language data typesJames Wong
 
Python language data types
Python language data typesPython language data types
Python language data typesYoung Alista
 
Python language data types
Python language data typesPython language data types
Python language data typesTony Nguyen
 

Similar a Yamata no Orochi Puppet Language 4.0 changes optimize expressiveness and type safety (20)

Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
Functional programming in ruby
Functional programming in rubyFunctional programming in ruby
Functional programming in ruby
 
Data Pipelines in Swift
Data Pipelines in SwiftData Pipelines in Swift
Data Pipelines in Swift
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In Erlang
 
Pre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to Elixir
 
Architecting Scalable Platforms in Erlang/OTP | Hamidreza Soleimani | Diginex...
Architecting Scalable Platforms in Erlang/OTP | Hamidreza Soleimani | Diginex...Architecting Scalable Platforms in Erlang/OTP | Hamidreza Soleimani | Diginex...
Architecting Scalable Platforms in Erlang/OTP | Hamidreza Soleimani | Diginex...
 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
 
Rakudo
RakudoRakudo
Rakudo
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potter
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
 
TDC2016SP - Trilha Programação Funcional
TDC2016SP - Trilha Programação FuncionalTDC2016SP - Trilha Programação Funcional
TDC2016SP - Trilha Programação Funcional
 
Haskell 101
Haskell 101Haskell 101
Haskell 101
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 

Más de Puppet

Puppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet
 
Puppetcamp r10kyaml
Puppetcamp r10kyamlPuppetcamp r10kyaml
Puppetcamp r10kyamlPuppet
 
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
 
Puppet camp vscode
Puppet camp vscodePuppet camp vscode
Puppet camp vscodePuppet
 
Modules of the twenties
Modules of the twentiesModules of the twenties
Modules of the twentiesPuppet
 
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 codePuppet
 
KGI compliance as-code approach
KGI compliance as-code approachKGI compliance as-code approach
KGI compliance as-code approachPuppet
 
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 automationPuppet
 
Keynote: Puppet camp compliance
Keynote: Puppet camp complianceKeynote: Puppet camp compliance
Keynote: Puppet camp compliancePuppet
 
Automating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNowAutomating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNowPuppet
 
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 WindowsPuppet
 
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. 2020Puppet
 
Accelerating azure adoption with puppet
Accelerating azure adoption with puppetAccelerating azure adoption with puppet
Accelerating azure adoption with puppetPuppet
 
Puppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael PinsonPuppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael PinsonPuppet
 
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 ReeuwijkPuppet
 
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 groundPuppet
 
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 SoftwarePuppet
 
Puppet User Group
Puppet User GroupPuppet User Group
Puppet User GroupPuppet
 
Continuous Compliance and DevSecOps
Continuous Compliance and DevSecOpsContinuous Compliance and DevSecOps
Continuous Compliance and DevSecOpsPuppet
 
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 MaludyPuppet
 

Más de 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
 

Último

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

Último (20)

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

Yamata no Orochi Puppet Language 4.0 changes optimize expressiveness and type safety

  • 1.
  • 3.
  • 4.
  • 5.
  • 6. Puppet Language 4.0 henrik.lindberg@puppetlabs.com
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. 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.
  • 13. Puppet 4.0 • Language Cleanup – Sanity, Principle of Least Surprise – Expressions, Expressions, Expressions • Features – Misc enhancements – Resource Expression Features – IteraGon – Type System / OpGonal Typing – Embedded Puppet Templates (EPP) – Heredoc
  • 14. Cleanup • Language SpecificaGon – yes we have one – hQps://github.com/puppetlabs/puppet-­‐specificaGons • Numbers are Numbers • No magic to-­‐string for =~ !~ in • Upper case bare words are Type References • Empty string is not undef (and thus "thruty") • InterpolaGon follows specified rules • +=, []= removed, no more mutaGon
  • 15.
  • 16. Misc new features 1(7) • 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}
  • 17. Misc new features 2(7) • Append to Array with << [1,2,3] << 4 => [1,2,3,4] [1,2,3] << [4,5,6] => [1,2,3,[4,5,6]]
  • 18. Misc new features 3(7) • Unfold with unary * $a = [2,3] $b = [1, *$a, 4] => [1,2,3,4] • Unfold in case opGon, 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]
  • 19. Misc new features 4(7) • Substring in string 'cd' in "abcde" => true • Substring with [] "xyzabcdef"[3,3] => "abc" "xyzabcdef"[3] => "a" "xyzabcdef"[3,-2] => "abcde"
  • 20. Misc new features 5(7) • Matches with Regexp in String form $a = "example.com" $url =~ "http://$a.*"
  • 21. Misc new features 6(7) • Detailed Error Messages – SemanGc validaGon unless lex or syntax errors – Outputs posiGon on line – Can report more than one error
  • 22. Expression Based Grammar 6(7) • if, unless, case are expressions notice if 1 > 2 { true } else { false } # => false $a = case 2 { 1, 2, 3: { yes } default: { no } } # => $a == yes
  • 24. Local Defaults file { default: mode => '444', owner => 'admin'; title: . . . ; }
  • 25. Unfold Hash file { default: * => $defaults_hash; 'tmp/foo': mode => '666', * => $params_hash; }
  • 26. Create Resources Equiv. in Puppet Resource[$type] { default: * => $defaults_hash; $titles: * => $params_hash; }
  • 27.
  • 28. LOOOOOOOPS • Iterate over: – Arrays – Hashes – Strings – Integer ranges • Implemented as funcGons taking callable code blocks (lambdas) = open design • Calls can now be expressed from leh to right using '.' notaGon
  • 29. each • Do something with each element • Returns LHS [1,2,3].each |$x| { notice $x } each([1,2,3]) |$x| { notice $x }
  • 30. map • Transform each element • Returns transformed result [1,2,3].map |$x| { $x*10 } => [10,20,30]
  • 31. filter • Produces elements that match • Returns filtered result [1,2,3].filter|$x| { $x >= 2 } => [2,3]
  • 32. reduce • Transforms / reduces many to one • Feeds seed/previous result into next iteraGon • Returns transformed result [1,2,3].reduce |$result, $x| { $result + $x } => 6
  • 34.
  • 35.
  • 36.
  • 38.
  • 40.
  • 42.
  • 43.
  • 45.
  • 46. The Puppet Type System Cow Integer
  • 47. 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']
  • 48. Example Integer # All integers Integer # All integers >=42 Integer[42] # All integers >=42 and <=142 Integer[42,142]
  • 49. AutomaGc type checking! define mytype(Integer[80,443] $port){ # port guaranteed to be integer # and between 80 and 443 # otherwise an error }
  • 50. More advanced 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
  • 51. OperaGons on Type • Since a Type is a kind of PaQern… – 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
  • 52. Type Hierarchy Any |- Scalar | |- Numeric | | |- Integer[from, to] | | |- Float[from, to] | | | |- String[from, to] | | |- Enum[*strings] | | |- Pattern[*patterns] | | | |- Boolean | |- Regexp[pattern_string]
  • 53. Type Hierarchy Any |- Collection | |- Array[T] | | |- Tuple[T*, from, to] | | | |- Hash[K, V] | | |- Struct[{ key => T, ...}] | |- Variant[T*] |- Optional[T] | |- Undef |- Default | |- Type[T]
  • 54. Type Hierarchy Any |- CatalogEntry | |- Resource[type_name, title] | |- Class[class_name] | |- Undef |- Data | |- Scalar | |- Array[Data] | |- Hash[Scalar, Data] | |- Undef
  • 55. EPP
  • 56. EPP – Templates in Puppet • Same template markup as ERB – Logic is Puppet instead of Ruby AND • Can be parameterized ! • Use funcGons epp(template) inline_epp(string) • instead of template() inline_template()
  • 57. Example EPP $x = 'human' inline_epp('This is not the <%= $x %> you are looking for.') # => 'This is not the human you are looking for.' $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.
  • 59. Puppet Heredoc • For more detailed control over a block of text • No, or selected set of escapes • InterpolaGon or no interpolaGon • Can be syntax checked by parser (JSon in core, can add plugin language support) • Control over leh margin
  • 60. Heredoc -­‐ Syntax ENDS-­‐HERE anything not in <text> "ENDS-­‐HERE" with interpola:on :json syntax check result /tsrn$L turns on escape / turns on all @( ["]<endtag>["] [:<syntax>] [/<escapes>] ) <text> [|][-] <endtag> | set le= margin -­‐ trim trailing t tab s space r return n new-­‐line $ $ L <end of line>
  • 61. 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
  • 63. Ruby API • 4x FuncGon API – type checked – dispatch to impl based on given types – more powerful – safer • Binder – composable type safe injecGon – for plugins and data (e.g. syntax checkers)
  • 64. Summary • Language Cleanup • More strict • New Features • BeQer Error Messages • IteraGon • Type System • Puppet Templates – EPP • Heredoc
  • 65. In pracGce • Run now with –parser future • Fix deprecaGons and issues • Make backwards compaGble changes and conGnue in producGon on 3x • Test carefully and conGnue running on what will be Puppet 4.0 • 4.0 expected release before end of the year
  • 66.
  • 67. Links • github/puppetlabs/puppet-­‐specificaGons • hQp://puppet-­‐on-­‐the-­‐edge.blogspot.com/ • TwiQer @hel • IRC helindbe