Puppet v4
Avoiding Dragons
Garrett Honeycutt
gh@learnpuppet.com
LearnPuppet.com
@learnpuppet
AIO
puppet-agent package from PC1
augeas (1.3.0) ruby (2.1.6)
cfacter (0.4.1) ruby-augeas (0.5.0)
facter (2.4.4) ruby-selinux
(2.0.94)
hiera (2.0.1) ruby-shadow (2.3.3)
marionette-collective (2.8.2) ruby-stomp (1.3.3)
openssl (1.0.0r) rubygem-deep-merge
(1.0.0)
puppet (4.1.0) rubygem-net-ssh (2.1.4)
virt-what (1.1.4)
Bye Bye
Apache+Passenge
r
Hello
JVM+Closure+JRu
by
Ruby 1.8.7
RIP
OSX <= 10.6
(snow leopard)
RIP
Where is
everything?
Mostly under
/opt/puppetlabs
/opt/puppetlabs/bin
Add to $PATH
/opt/puppetlabs/puppet/bin
Private programs for Puppet
such as ruby and gem
configuration is in
/etc/puppetlabs/puppet
$ ls /etc/puppetlabs
code
mcollective
puppet
puppetserver
SSL where!?
/etc/puppetlabs/puppet/ssl
/etc/puppetlabs/code
Hiera configuration
Hiera data
Static modules
Environments
Environments
/etc/puppetlabs/code/environments
Many
type/provider
improvements
Facts are not
all strings
$ facter os --yaml
---
os:
name: CentOS
family: RedHat
release:
major: '7'
minor: '1'
full: 7.1.1503
class foo (
$bar = true,
) {
if is_string($bar) == true {
$bar_real = str2bool($bar)
} else {
$bar_real = $bar
}
validate_bool($bar_real)
}
Templates with
EPP
epp(module/foo.epp)
Language
Iteration with
lambdas
.each is here
$list = ['a','b','c']
each($list) |$index, $value|
{
notice("${index} = ${value}")
}
Notice: Scope(Class[main]): 0 = a
Notice: Scope(Class[main]): 1 = b
Notice: Scope(Class[main]): 2 = c
['a','b','c'].each |$index, $value|
{
notice("${index} = ${value}")
}
Notice: Scope(Class[main]): 0 = a
Notice: Scope(Class[main]): 1 = b
Notice: Scope(Class[main]): 2 = c
Lambdas
.each
.slice
.filter
.map
.reduce
.with
Type casting
class foo (
$bar = true,
) {
if is_string($bar) == true {
$bar_real = str2bool($bar)
} else {
$bar_real = $bar
}
validate_bool($bar_real)
}
class foo (
Boolean $bar = true,
) {
# Remove all this code!
#
# if is_string($bar) == true {
# $bar_real = str2bool($bar)
# } else {
# $bar_real = $bar
# }
# validate_bool($bar_real)
}
String
Integer, Float, and Numeric
Boolean
Array
Hash
Regexp
Undef
Default
Scalar Struct
Collection Optional
Variant Catalogentry
Data Type
Pattern Any
Enum Callable
Tuple
Upgrading
Never upgrade
in place
Create new
puppet
masters
common nscd rsyslog
dnsclient nsswitch selinux
facter ntp ssh
hosts pam
sysklogd
inittab papertrail timezone
localization puppet types
nfs redhat utils
nrpe rpcbind vim
Travis-ci
# spec/spec_helper.rb
RSpec.configure do |config|
config.before :each do
Puppet[:parser] = 'future' if
ENV['PARSER'] == 'future'
end
end
# .travis.yml
env:
matrix:
- PUPPET_GEM_VERSION="~> 3.1"
- PUPPET_GEM_VERSION="~> 3.2"
- PUPPET_GEM_VERSION="~> 3.3"
- PUPPET_GEM_VERSION="~> 3.4"
- PUPPET_GEM_VERSION="~> 3.5"
- PUPPET_GEM_VERSION="~> 3.6"
- PUPPET_GEM_VERSION="~> 3.7"
- PUPPET_GEM_VERSION="~> 3.8"
- PUPPET_GEM_VERSION="~> 3" PARSER="future"
- PUPPET_GEM_VERSION="~> 4.0"
- PUPPET_GEM_VERSION="~> 4.1"
- PUPPET_GEM_VERSION="~> 4"
# .travis.yml
---
language: ruby
rvm:
- 2.1.0
sudo: false
env:
matrix:
- PUPPET_GEM_VERSION="~> 3" PARSER="future"
- PUPPET_GEM_VERSION="~> 4"
script: 'bundle exec metadata-json-lint metadata.json && bundle
exec rake validate && bundle exec rake lint && SPEC_OPTS="--
format documentation" bundle exec rake spec'
matrix:
fast_finish: true
notifications:
email: false
Resource
Overrides
Service ['nfs_service'] {
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
Service['nfs_service'] {
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
type()
Error: Illegal
expression. A
Reserved Word
'type' is
unacceptable as
function name
type3x()
stdlib
puppetlabs/stdlib >= 4.6.0 < 6.0.0
v4.6.0 includes type3x()
validate_absolute_path()
Now accepts arrays :)
Broke my spec tests :(
Error codes changed
slightly
Broke my spec tests :(
expected Puppet::Error with
message matching /^true is
not a string/, got
#<Puppet::Error: Evaluation
Error: Error while
evaluating a Function Call,
true is not a string. It
looks to be a TrueClass
Got rid of '^' in regex so it was not
being as explicit.
Templates
Must have @var instead of just var.
Check inline_template() too.
Stop using
inline_template()
Node
Inheritance
RIP
node common {
include ssh
}
node 'f.example.com' inherits common {
include apache
}
Upgrade Checklist
* setup Travis (or equiv)
* test
* test
* test
Puppet v4
Avoiding Dragons
Garrett Honeycutt
gh@learnpuppet.com
LearnPuppet.com
@learnpuppet

20150613 self-puppet v4-avoiding_dragons