SlideShare a Scribd company logo
Our Puppet Story – Patterns and
Learnings
Martin Schütte
March 27 2014
1. Intro
2. Vagrant
3. Puppet
Intro
Dashboard & PE
Facter & Hiera
git
Problems
Misc
1. Intro
2. Vagrant
3. Puppet
Intro
Dashboard & PE
Facter & Hiera
git
Problems
Misc
About DECK36
• Small team of 7 engineers
• Longstanding expertise in designing, implementing and operating
complex web systems
• Developing own data intelligence-focused tools and web services
• Offering our expert knowledge in Automation & Operation,
Architecture & Engineering, Analytics & Data Logistics
About me
• System Automation Engineer
• Puppet Certified Professional 2013
• martin.schuette@deck36.de
The Problem
The Goal
Stable and reproducible environment for a Software.
… environment for new developer,
… test config changes,
… clean package build env,
… preconfigured demo box.
But also quickly deployable, and centrally managed
with current software versions.
1. Intro
2. Vagrant
3. Puppet
Intro
Dashboard & PE
Facter & Hiera
git
Problems
Misc
Vagrant
Configuration tool for VMs and Provisioning.
“Local cloud”
• Self service
• Instant provisioning
• Cost efficient
• Elastic
• Pay per use
Vagrant
VM Providers:
• VirtualBox: “default”, works offline, ressource hungry
• Docker: lightweight, requires Linux, good for testing
• AWS EC2: remote VMs, good for automation (Jenkins)
Provisioning:
• Shell script
• Puppet, apply manifest or run agent
• Chef, solo or client
• Ansible playbooks
• Salt states
• Docker containers
VeeWee definition
Veewee::Definition.declare({
:iso_file => "debian-wheezy-DI-b4-amd64-netinst.iso",
:disk_size => '40560', :disk_format => 'VDI',
:cpu_count => '2', :memory_size => '3192',
:boot_wait => "10", :boot_cmd_sequence => [
'<Esc>', 'install ',
'preseed/url=http://%IP%:%PORT%/preseed.cfg ',
'debconf/frontend=noninteractive ', '<Enter>'
],
:postinstall_files => [
"base.sh", "vagrant.sh", "customize-puppet.sh", ...
],
...
})
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "graylog2"
config.vm.box_url = "http://vagrantboxes.footballradar.com/wheezy64.box"
config.vm.provider "virtualbox" do |v|
v.memory = 1024
end
config.vm.provision :puppet do |puppet|
puppet.manifest_file = "graylog2.pp"
puppet.module_path = "modules"
end
config.vm.network :forwarded_port, guest: 9000, host: 9000
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 12201, host: 12201, protocol: 'udp'
config.vm.network :forwarded_port, guest: 12201, host: 12201, protocol: 'tcp'
config.vm.network :forwarded_port, guest: 12900, host: 12900
end
Multi-VM Vagrantfile
Vagrant.configure("2") do |config|
# VM 1: appserver
config.vm.define :app do |app|
app.vm.hostname = "testbox.example.org"
app.vm.network :forwarded_port, host: 8080, guest: 80
app.vm.synced_folder ".", "/home/vagrant/files"
end
# VM 2: DB server
config.vm.define :db do |db|
db.vm.hostname = "db.example.org"
db.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
end
# Box & Provisioning
config.vm.box = "precise64"
config.vm.provision :shell,
:path => "vagrant_install_puppet_keys.sh"
config.vm.provision :puppet_server,
:puppet_server => "puppetmaster.example.org"
end
vagrant-aws
Vagrant.configure("2") do |config|
config.vm.box = "dummy"
config.vm.provider :aws do |aws, override|
aws.access_key_id = "YOUR KEY"
aws.secret_access_key = "YOUR SECRET KEY"
aws.keypair_name = "KEYPAIR NAME"
region = "eu-west-1"
aws.ami = "ami-20414854"
aws.tags = {
'Role' => 'TestVM',
'Net' => 'Devnet'
}
end
end
Synced Folders
Shared folders, mounted from host into guest.
Options:
• VirtualBox
• NFS
• SMB
• rsync
Synced Folders
src: Mitchell Hashimoto, Comparing Filesystem Performance in Virtual Machines
1. Intro
2. Vagrant
3. Puppet
Intro
Dashboard & PE
Facter & Hiera
git
Problems
Misc
Puppet
• Configuration Management
• Declarative: Resources and Dependencies
Puppet
Puppet Agent execution:
1. Create catalog:
• read manifest
• gather resources
• ensure order
2. Apply for each resource:
• query state
• change to desired state
Syntax
class vpn($version = 'present', $ca_crt, $usr_crt, $usr_key) {
package {
'openvpn':
ensure => $version;
}
file {
"/etc/openvpn/client.key":
ensure => file,
mode => '0600',
content => $usr_key;
require => Package['openvpn'],
notify => Service['openvpn'];
"/etc/openvpn/client.conf":
ensure => file,
source => "puppet:///modules/vpn/client.conf",
require => Package['openvpn'],
notify => Service['openvpn'];
}
service { 'openvpn':
ensure => running,
require => Package['openvpn'],
}
}
Syntax
class vpn($version = 'present', $ca_crt, $usr_crt, $usr_key) {
package {
'openvpn':
ensure => $version;
}
->
file {
"/etc/openvpn/client.key":
ensure => file,
mode => '0600',
content => $usr_key;
"/etc/openvpn/client.conf":
ensure => file,
source => "puppet:///modules/vpn/client.conf";
}
~>
service { 'openvpn':
ensure => running,
}
}
Relationships
Class[Vpn]
Package[openvpn]
File[/etc/openvpn/client.key] File[/etc/openvpn/client.conf]
Service[openvpn]
Puppet Module Layout
module_name
• manifests Puppet code (classes/defines)
- init.pp
- subclass.pp
• files static files
• templates .erb templates
• lib ruby plugins (custom types/facts)
• tests usage examples for manifests
• spec spec tests for libs
Puppet Dashboard
External Monitoring
stdlib facts.d
• simple data input
• e. g. ec2metadata, inventory lookup
custom_facts.sh
#! /bin/sh
which ec2metadata >/dev/null 2>&1 || exit 1
echo "ec2_ami_id=$(ec2metadata --ami-id)"
echo "ec2_instance_id=$(ec2metadata --instance-id)"
echo "ec2_instance_type=$(ec2metadata --instance-type)"
echo "ec2_public_ipv4=$(ec2metadata --public-ipv4)"
echo "ec2_public_hostname=$(ec2metadata --public-hostname)"
Hiera
• banish top scope variables
• use Hiera!
• structure with roles & profiles
node definitions vs. Hiera
site.pp
node "mydev.vagrantup.com" inherits basenode-vagrant {
$vmEnv = "development"
include sysadmin
include ntp
include vagrant
include user::vagrant
include mysqlserver
include redisserver
# ...
}
node definitions vs. Hiera
site.pp
hiera_include('include_classes', ['sysadmin'])
node default {
}
role_elasticsearch.yaml
include_classes:
- elasticsearch
- elasticsearch::plugins
- zabbix::helper::elasticsearch
elasticsearch::clustername: "mycluster"
elasticsearch::client: false
elasticsearch::heapsize: "768m"
hiera.yaml
:hierarchy:
- node/%{fqdn}
- vm/netenv_role_%{puppet_netenv}_%{puppet_role}
- vm/role_%{puppet_role}
- vm/netenv_%{puppet_netenv}
- domain_%{domain}
- common
:backends:
- yaml
:logger: console
:yaml:
:datadir: "/etc/puppet/environments/%{environment}/"
Example lookup
fqdn = dev.pod1.org
domain = pod1.org
puppet_role = dev
puppet_netenv = vagrant
⇒ Lookup in:
1. node/dev.pod1.org.yaml
2. vm/netenv_role_vagrant_dev.yaml
3. vm/role_dev.yaml
4. vm/netenv_vagrant.yaml
5. domain_pod1.org.yaml
6. common.yaml
Hiera & Puppet 2.x compatibility
class vpn($version = hiera('vpn::version', 'present'),
$ca_crt = hiera('vpn::ca_crt'),
$usr_crt = hiera('vpn::usr_crt'),
$usr_key = hiera('vpn::usr_key')) {
package {
'openvpn':
ensure => $version;
}
# ...
}
git workflow
• use git!
• use git hooks
• use per-user environments for easy testing
• repos for testing/production
git hook: Syntax Check
Git pre-commit hook with puppet-lint to syntax check Puppet, ERB
templates, YAML files (http://github.com/gini/puppet-git-hooks)
Example Output:
$ git commit -m 'test' modules/graylog2/templates/server.conf.erb
-:5: syntax error, unexpected $undefined
...rd_sha2 = "; _erbout.concat(( @ root_pwd_sha2 ).to_s); _erbo...
... ^
ERB syntax error in modules/graylog2/templates/server.conf.erb
git hook: E-Mail Notification
Git post-receive hook to notify team on push
(http://git.kernel.org/cgit/git/git.git/tree/contrib/hooks/
post-receive-email?id=HEAD)
Example E-Mail:
- Log ----------------------------------------------
commit 5df04ee883b8de8a37bf0ac97eec068cd1f3a414
Author: N. N. <n.n@deck36.de>
Date: Tue Jan 7 08:57:17 2014 +0000
fixed path to csync2 executable
----------------------------------------------------
Summary of changes:
modules/user/files/etc/sudoers.d/support | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
environments
• per user env + production
⇒ easy testing with puppet agent -t --environment=user
• two servers for testing/production
Config (in puppet < 3.5.0):
puppet.conf
[mschuette]
modulepath = $confdir/environments/mschuette/modules
manifest = $confdir/environments/mschuette/manifests/site.pp
pluginsync = true
environments
..dev-master. prod-master.
user1
.user2 .
user3
.
…
.
Dev/Test
.
Prod
Puppet Problems
• some tasks require two agent runs
• apt-get upgrade and package dependencies
• beware of version mismatch between apt (or yum) and package
• scoping and namespaces
• exec is the new eval
Version ping-pong
modules/php/init.pp
class php($version = '5.3.10-1ubuntu3.10') {
package { 'php5-common':
ensure => $version,
}
}
class php::curl($version) {
require php
package { 'php5-curl':
ensure => $version,
}
}
server.pp
class { 'php::curl':
version => '5.5.5+dfsg-1+debphp.org~precise+2',
}
Namespace problems
# this does not work, cf. #PUP-1073
package { 'memcached':
ensure => present,
provider => apt,
}
package { 'memcached':
ensure => present,
provider => gem,
}
exec tricks
You can do (and break) everything with exec.
But of course you should not.
exec tricks
# no pkg provider for npm
exec { 'npm install -g less':
creates => '/usr/lib/node_modules/npm/node_modules/less',
}
# hide change
exec { 'zabbix_update.sh':
command => 'false',
onlyif => "/opt/zabbix_update.sh $api_url && false",
logoutput => on_failure,
}
MCollective
“multissh deluxe”
AMQP client/server framework to
• orchestrate actions
• control puppet agents
• run commands
• query resources
• …
Hooks to other systems
• include in provisioning process
• provide normative data as facts
• register or update DNS name → Route 53
• register or update host in Zabbix monitoring → API
Versions
• Puppet 2.7: legacy
• Puppet 3.0: major upgrade, with Hiera support
• Puppet 3.x: current development, future parser
Questions?
class presentation {
package { 'questions':
ensure => 'answered',
}
}
Links:
• Vagrant
• Puppet Language: Visual Index
• Puppet Type Reference
• Puppet Ask
Thank You

More Related Content

PDF
PuppetDB: Sneaking Clojure into Operations
PDF
Practicing Continuous Deployment
KEY
Making Your Capistrano Recipe Book
PDF
Ansible 實戰:top down 觀點
PDF
Percona Toolkit for Effective MySQL Administration
PDF
Apache ZooKeeper
PPTX
An Ensemble Core with Docker - Solving a Real Pain in the PaaS
PDF
Introduction to Apache ZooKeeper | Big Data Hadoop Spark Tutorial | CloudxLab
PuppetDB: Sneaking Clojure into Operations
Practicing Continuous Deployment
Making Your Capistrano Recipe Book
Ansible 實戰:top down 觀點
Percona Toolkit for Effective MySQL Administration
Apache ZooKeeper
An Ensemble Core with Docker - Solving a Real Pain in the PaaS
Introduction to Apache ZooKeeper | Big Data Hadoop Spark Tutorial | CloudxLab

What's hot (20)

PPTX
Introduction to apache zoo keeper
PDF
Build Automation 101
PDF
Distributed system coordination by zookeeper and introduction to kazoo python...
PDF
Ansible not only for Dummies
PDF
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
PPTX
Herd your chickens: Ansible for DB2 configuration management
PDF
How and Why Prometheus' New Storage Engine Pushes the Limits of Time Series D...
PDF
Take control of your Jenkins jobs via job DSL.
PPTX
Introduction to Apache ZooKeeper
PDF
Getting started with Ansible
PDF
Automation with Ansible and Containers
PDF
Fixing Growing Pains With Puppet Data Patterns
PDF
PostgreSQL Extensions: A deeper look
PPTX
Docker on openstack by OpenSource Consulting
PPTX
Apache zookeeper 101
PDF
Advanced task management with Celery
PDF
Automated Java Deployments With Rpm
PDF
Zookeeper In Simple Words
PDF
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
PDF
PuppetConf 2016: Nano Server, Puppet, and DSC
Introduction to apache zoo keeper
Build Automation 101
Distributed system coordination by zookeeper and introduction to kazoo python...
Ansible not only for Dummies
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
Herd your chickens: Ansible for DB2 configuration management
How and Why Prometheus' New Storage Engine Pushes the Limits of Time Series D...
Take control of your Jenkins jobs via job DSL.
Introduction to Apache ZooKeeper
Getting started with Ansible
Automation with Ansible and Containers
Fixing Growing Pains With Puppet Data Patterns
PostgreSQL Extensions: A deeper look
Docker on openstack by OpenSource Consulting
Apache zookeeper 101
Advanced task management with Celery
Automated Java Deployments With Rpm
Zookeeper In Simple Words
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
PuppetConf 2016: Nano Server, Puppet, and DSC
Ad

Viewers also liked (20)

PDF
Revista33
PPTX
Presentación Xorcom - Nordata
DOC
Download the complete course information(.doc)
ODP
Organizing used parts in the DIY bicycle shop
PDF
Ideas prácticas para emprendedores
DOCX
Actividad 1 cognicion
DOCX
Historia de la Hotelería de Manta - Manabí - Ecuador
PDF
deep books catalague 2015 - Health & Complementary Therapies
PDF
Figures of Absence in the History of Art
PDF
PDF
JSI Swish Brochure
PDF
Perini 2007_Annual_Report
PPTX
Primera reunión comunidad tecnológica 06 05-2010
PDF
Gracias4b2
PPTX
Things to remember before taking your sol, notes for students
PPT
6ta Clase Modelos a escala
PPT
CORE: Cognitive Organization for Requirements Elicitation
PPT
Lean Mfg Takeawayssharing
PDF
TD Systems Information
Revista33
Presentación Xorcom - Nordata
Download the complete course information(.doc)
Organizing used parts in the DIY bicycle shop
Ideas prácticas para emprendedores
Actividad 1 cognicion
Historia de la Hotelería de Manta - Manabí - Ecuador
deep books catalague 2015 - Health & Complementary Therapies
Figures of Absence in the History of Art
JSI Swish Brochure
Perini 2007_Annual_Report
Primera reunión comunidad tecnológica 06 05-2010
Gracias4b2
Things to remember before taking your sol, notes for students
6ta Clase Modelos a escala
CORE: Cognitive Organization for Requirements Elicitation
Lean Mfg Takeawayssharing
TD Systems Information
Ad

Similar to Our Puppet Story – Patterns and Learnings (sage@guug, March 2014) (20)

PPT
Puppet
PDF
Our Puppet Story (Linuxtag 2014)
PDF
DevOps Series: Extending vagrant with Puppet for configuration management
KEY
Puppet for Java developers - JavaZone NO 2012
PDF
20090514 Introducing Puppet To Sasag
PDF
Puppet and the HashiStack
PDF
Test driven infrastructure
PDF
Our Puppet Story (GUUG FFG 2015)
PDF
Security Testing Using Infrastructure-As-Code
PDF
Puppet: From 0 to 100 in 30 minutes
PDF
Intro to-puppet
PPT
Getting Started with Puppet by Chad Metcalf Wibi Data
PDF
Getting started with puppet and vagrant (1)
ODP
Puppet and the HashiCorp Suite
PDF
SCM Puppet: from an intro to the scaling
PDF
Puppet and Vagrant in development
PPTX
Harmonious Development: Via Vagrant and Puppet
KEY
From Dev to DevOps - FOSDEM 2012
PPTX
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
PPTX
Puppet
Our Puppet Story (Linuxtag 2014)
DevOps Series: Extending vagrant with Puppet for configuration management
Puppet for Java developers - JavaZone NO 2012
20090514 Introducing Puppet To Sasag
Puppet and the HashiStack
Test driven infrastructure
Our Puppet Story (GUUG FFG 2015)
Security Testing Using Infrastructure-As-Code
Puppet: From 0 to 100 in 30 minutes
Intro to-puppet
Getting Started with Puppet by Chad Metcalf Wibi Data
Getting started with puppet and vagrant (1)
Puppet and the HashiCorp Suite
SCM Puppet: from an intro to the scaling
Puppet and Vagrant in development
Harmonious Development: Via Vagrant and Puppet
From Dev to DevOps - FOSDEM 2012
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Electronic commerce courselecture one. Pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation theory and applications.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Spectral efficient network and resource selection model in 5G networks
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Electronic commerce courselecture one. Pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MYSQL Presentation for SQL database connectivity
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction
Encapsulation theory and applications.pdf
cuic standard and advanced reporting.pdf
Encapsulation_ Review paper, used for researhc scholars
20250228 LYD VKU AI Blended-Learning.pptx
Unlocking AI with Model Context Protocol (MCP)

Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)

  • 1. Our Puppet Story – Patterns and Learnings Martin Schütte March 27 2014
  • 2. 1. Intro 2. Vagrant 3. Puppet Intro Dashboard & PE Facter & Hiera git Problems Misc
  • 3. 1. Intro 2. Vagrant 3. Puppet Intro Dashboard & PE Facter & Hiera git Problems Misc
  • 4. About DECK36 • Small team of 7 engineers • Longstanding expertise in designing, implementing and operating complex web systems • Developing own data intelligence-focused tools and web services • Offering our expert knowledge in Automation & Operation, Architecture & Engineering, Analytics & Data Logistics
  • 5. About me • System Automation Engineer • Puppet Certified Professional 2013 • martin.schuette@deck36.de
  • 7. The Goal Stable and reproducible environment for a Software. … environment for new developer, … test config changes, … clean package build env, … preconfigured demo box. But also quickly deployable, and centrally managed with current software versions.
  • 8. 1. Intro 2. Vagrant 3. Puppet Intro Dashboard & PE Facter & Hiera git Problems Misc
  • 9. Vagrant Configuration tool for VMs and Provisioning. “Local cloud” • Self service • Instant provisioning • Cost efficient • Elastic • Pay per use
  • 10. Vagrant VM Providers: • VirtualBox: “default”, works offline, ressource hungry • Docker: lightweight, requires Linux, good for testing • AWS EC2: remote VMs, good for automation (Jenkins) Provisioning: • Shell script • Puppet, apply manifest or run agent • Chef, solo or client • Ansible playbooks • Salt states • Docker containers
  • 11. VeeWee definition Veewee::Definition.declare({ :iso_file => "debian-wheezy-DI-b4-amd64-netinst.iso", :disk_size => '40560', :disk_format => 'VDI', :cpu_count => '2', :memory_size => '3192', :boot_wait => "10", :boot_cmd_sequence => [ '<Esc>', 'install ', 'preseed/url=http://%IP%:%PORT%/preseed.cfg ', 'debconf/frontend=noninteractive ', '<Enter>' ], :postinstall_files => [ "base.sh", "vagrant.sh", "customize-puppet.sh", ... ], ... })
  • 12. Vagrantfile Vagrant.configure("2") do |config| config.vm.box = "graylog2" config.vm.box_url = "http://vagrantboxes.footballradar.com/wheezy64.box" config.vm.provider "virtualbox" do |v| v.memory = 1024 end config.vm.provision :puppet do |puppet| puppet.manifest_file = "graylog2.pp" puppet.module_path = "modules" end config.vm.network :forwarded_port, guest: 9000, host: 9000 config.vm.network :forwarded_port, guest: 80, host: 8080 config.vm.network :forwarded_port, guest: 12201, host: 12201, protocol: 'udp' config.vm.network :forwarded_port, guest: 12201, host: 12201, protocol: 'tcp' config.vm.network :forwarded_port, guest: 12900, host: 12900 end
  • 13. Multi-VM Vagrantfile Vagrant.configure("2") do |config| # VM 1: appserver config.vm.define :app do |app| app.vm.hostname = "testbox.example.org" app.vm.network :forwarded_port, host: 8080, guest: 80 app.vm.synced_folder ".", "/home/vagrant/files" end # VM 2: DB server config.vm.define :db do |db| db.vm.hostname = "db.example.org" db.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--cpus", "2"] end end # Box & Provisioning config.vm.box = "precise64" config.vm.provision :shell, :path => "vagrant_install_puppet_keys.sh" config.vm.provision :puppet_server, :puppet_server => "puppetmaster.example.org" end
  • 14. vagrant-aws Vagrant.configure("2") do |config| config.vm.box = "dummy" config.vm.provider :aws do |aws, override| aws.access_key_id = "YOUR KEY" aws.secret_access_key = "YOUR SECRET KEY" aws.keypair_name = "KEYPAIR NAME" region = "eu-west-1" aws.ami = "ami-20414854" aws.tags = { 'Role' => 'TestVM', 'Net' => 'Devnet' } end end
  • 15. Synced Folders Shared folders, mounted from host into guest. Options: • VirtualBox • NFS • SMB • rsync
  • 16. Synced Folders src: Mitchell Hashimoto, Comparing Filesystem Performance in Virtual Machines
  • 17. 1. Intro 2. Vagrant 3. Puppet Intro Dashboard & PE Facter & Hiera git Problems Misc
  • 18. Puppet • Configuration Management • Declarative: Resources and Dependencies
  • 19. Puppet Puppet Agent execution: 1. Create catalog: • read manifest • gather resources • ensure order 2. Apply for each resource: • query state • change to desired state
  • 20. Syntax class vpn($version = 'present', $ca_crt, $usr_crt, $usr_key) { package { 'openvpn': ensure => $version; } file { "/etc/openvpn/client.key": ensure => file, mode => '0600', content => $usr_key; require => Package['openvpn'], notify => Service['openvpn']; "/etc/openvpn/client.conf": ensure => file, source => "puppet:///modules/vpn/client.conf", require => Package['openvpn'], notify => Service['openvpn']; } service { 'openvpn': ensure => running, require => Package['openvpn'], } }
  • 21. Syntax class vpn($version = 'present', $ca_crt, $usr_crt, $usr_key) { package { 'openvpn': ensure => $version; } -> file { "/etc/openvpn/client.key": ensure => file, mode => '0600', content => $usr_key; "/etc/openvpn/client.conf": ensure => file, source => "puppet:///modules/vpn/client.conf"; } ~> service { 'openvpn': ensure => running, } }
  • 23. Puppet Module Layout module_name • manifests Puppet code (classes/defines) - init.pp - subclass.pp • files static files • templates .erb templates • lib ruby plugins (custom types/facts) • tests usage examples for manifests • spec spec tests for libs
  • 26. stdlib facts.d • simple data input • e. g. ec2metadata, inventory lookup custom_facts.sh #! /bin/sh which ec2metadata >/dev/null 2>&1 || exit 1 echo "ec2_ami_id=$(ec2metadata --ami-id)" echo "ec2_instance_id=$(ec2metadata --instance-id)" echo "ec2_instance_type=$(ec2metadata --instance-type)" echo "ec2_public_ipv4=$(ec2metadata --public-ipv4)" echo "ec2_public_hostname=$(ec2metadata --public-hostname)"
  • 27. Hiera • banish top scope variables • use Hiera! • structure with roles & profiles
  • 28. node definitions vs. Hiera site.pp node "mydev.vagrantup.com" inherits basenode-vagrant { $vmEnv = "development" include sysadmin include ntp include vagrant include user::vagrant include mysqlserver include redisserver # ... }
  • 29. node definitions vs. Hiera site.pp hiera_include('include_classes', ['sysadmin']) node default { } role_elasticsearch.yaml include_classes: - elasticsearch - elasticsearch::plugins - zabbix::helper::elasticsearch elasticsearch::clustername: "mycluster" elasticsearch::client: false elasticsearch::heapsize: "768m"
  • 30. hiera.yaml :hierarchy: - node/%{fqdn} - vm/netenv_role_%{puppet_netenv}_%{puppet_role} - vm/role_%{puppet_role} - vm/netenv_%{puppet_netenv} - domain_%{domain} - common :backends: - yaml :logger: console :yaml: :datadir: "/etc/puppet/environments/%{environment}/"
  • 31. Example lookup fqdn = dev.pod1.org domain = pod1.org puppet_role = dev puppet_netenv = vagrant ⇒ Lookup in: 1. node/dev.pod1.org.yaml 2. vm/netenv_role_vagrant_dev.yaml 3. vm/role_dev.yaml 4. vm/netenv_vagrant.yaml 5. domain_pod1.org.yaml 6. common.yaml
  • 32. Hiera & Puppet 2.x compatibility class vpn($version = hiera('vpn::version', 'present'), $ca_crt = hiera('vpn::ca_crt'), $usr_crt = hiera('vpn::usr_crt'), $usr_key = hiera('vpn::usr_key')) { package { 'openvpn': ensure => $version; } # ... }
  • 33. git workflow • use git! • use git hooks • use per-user environments for easy testing • repos for testing/production
  • 34. git hook: Syntax Check Git pre-commit hook with puppet-lint to syntax check Puppet, ERB templates, YAML files (http://github.com/gini/puppet-git-hooks) Example Output: $ git commit -m 'test' modules/graylog2/templates/server.conf.erb -:5: syntax error, unexpected $undefined ...rd_sha2 = "; _erbout.concat(( @ root_pwd_sha2 ).to_s); _erbo... ... ^ ERB syntax error in modules/graylog2/templates/server.conf.erb
  • 35. git hook: E-Mail Notification Git post-receive hook to notify team on push (http://git.kernel.org/cgit/git/git.git/tree/contrib/hooks/ post-receive-email?id=HEAD) Example E-Mail: - Log ---------------------------------------------- commit 5df04ee883b8de8a37bf0ac97eec068cd1f3a414 Author: N. N. <n.n@deck36.de> Date: Tue Jan 7 08:57:17 2014 +0000 fixed path to csync2 executable ---------------------------------------------------- Summary of changes: modules/user/files/etc/sudoers.d/support | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
  • 36. environments • per user env + production ⇒ easy testing with puppet agent -t --environment=user • two servers for testing/production Config (in puppet < 3.5.0): puppet.conf [mschuette] modulepath = $confdir/environments/mschuette/modules manifest = $confdir/environments/mschuette/manifests/site.pp pluginsync = true
  • 38. Puppet Problems • some tasks require two agent runs • apt-get upgrade and package dependencies • beware of version mismatch between apt (or yum) and package • scoping and namespaces • exec is the new eval
  • 39. Version ping-pong modules/php/init.pp class php($version = '5.3.10-1ubuntu3.10') { package { 'php5-common': ensure => $version, } } class php::curl($version) { require php package { 'php5-curl': ensure => $version, } } server.pp class { 'php::curl': version => '5.5.5+dfsg-1+debphp.org~precise+2', }
  • 40. Namespace problems # this does not work, cf. #PUP-1073 package { 'memcached': ensure => present, provider => apt, } package { 'memcached': ensure => present, provider => gem, }
  • 41. exec tricks You can do (and break) everything with exec. But of course you should not.
  • 42. exec tricks # no pkg provider for npm exec { 'npm install -g less': creates => '/usr/lib/node_modules/npm/node_modules/less', } # hide change exec { 'zabbix_update.sh': command => 'false', onlyif => "/opt/zabbix_update.sh $api_url && false", logoutput => on_failure, }
  • 43. MCollective “multissh deluxe” AMQP client/server framework to • orchestrate actions • control puppet agents • run commands • query resources • …
  • 44. Hooks to other systems • include in provisioning process • provide normative data as facts • register or update DNS name → Route 53 • register or update host in Zabbix monitoring → API
  • 45. Versions • Puppet 2.7: legacy • Puppet 3.0: major upgrade, with Hiera support • Puppet 3.x: current development, future parser
  • 46. Questions? class presentation { package { 'questions': ensure => 'answered', } } Links: • Vagrant • Puppet Language: Visual Index • Puppet Type Reference • Puppet Ask