20150613 self-puppet v4-avoiding_dragons
-
Upload
garrett-honeycutt -
Category
Engineering
-
view
247 -
download
1
Transcript of 20150613 self-puppet v4-avoiding_dragons
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 ByeApache+Passenge
r
HelloJVM+Closure+JRu
by
Ruby 1.8.7
RIP
OSX <= 10.6(snow leopard)
RIP
Where iseverything?
Mostly under/opt/puppetlabs
/opt/puppetlabs/bin
Add to $PATH
/opt/puppetlabs/puppet/bin
Private programs for Puppetsuch 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
Manytype/providerimprovements
Facts are notall 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 withEPP
epp(module/foo.epp)
Language
Iteration withlambdas
.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 upgradein place
Create newpuppetmasters
common nscd rsyslog
dnsclient nsswitch selinux
facter ntp ssh
hosts pamsysklogd
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 && bundleexec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
matrix:
fast_finish: true
notifications:
email: false
ResourceOverrides
Service ['nfs_service'] {
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
Service['nfs_service'] {
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
type()
Error: Illegalexpression. AReserved Word'type' isunacceptable asfunction 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 changedslightly
Broke my spec tests :(
expected Puppet::Error withmessage matching /^true isnot a string/, got
#<Puppet::Error: EvaluationError: Error whileevaluating a Function Call,true is not a string. Itlooks to be a TrueClass
Got rid of '^' in regex so it was notbeing as explicit.
Templates
Must have @var instead of just var.
Check inline_template() too.
Stop using inline_template()
NodeInheritance
RIP
node common {
include ssh
}
node 'f.example.com' inherits common {
include apache
}
Upgrade Checklist
* setup Travis (or equiv)* test* test* test