2014-11-11 multiple approaches to managing puppet modules @ puppet camp seattle

72
Multiple approaches to managing your Puppet modules Puppet Camp Seattle 2014-11-11 Seattle, WA LearnPuppet.com Garrett Honeycutt [email protected] @learnpuppet

Upload: garrett-honeycutt

Post on 30-Jun-2015

265 views

Category:

Engineering


4 download

DESCRIPTION

Discuss puppet modules and different ways of managing them, including librarian-puppet, librarian-puppet-simple, and r10k.

TRANSCRIPT

Page 1: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Multiple approaches tomanaging your Puppet

modulesPuppet Camp Seattle

2014-11-11

Seattle, WA

LearnPuppet.comGarrett Honeycutt

[email protected]@learnpuppet

Page 2: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

# whoami

http://www.linkedin.com/in/garretthoneycutt© 2014 GH Solutions, LLC

Page 3: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

LearnPuppet.comAudits

Consulting

TrainingAdvanced Topics with Test Driven Development

© 2014 GH Solutions, LLC

Page 4: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

@fossetcon

© 2014 GH Solutions, LLC

Page 5: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

© 2014 GH Solutions, LLC

Page 6: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

What is a Module?© 2014 GH Solutions, LLC

Page 7: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

ModulesA module is a self contained directory structure for encapsulating

puppet code.© 2014 GH Solutions, LLC

Page 8: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Metadata# Modulefile

name 'ghoneycutt-nscd'version '1.0.2'source 'git://github.com/ghoneycutt/puppet-module-nscd.git'author 'ghoneycutt'license 'Apache License, Version 2.0'summary 'manage NSCD - name service cache daemon'description 'Manage every aspect of NSCD - name service cache daemon'project_page 'https://github.com/ghoneycutt/puppet-module-nscd'dependency 'puppetlabs/stdlib', '>= 3.2.0'

© 2014 GH Solutions, LLC

Page 9: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Metadata# metadata.json{ "name": "ghoneycutt-nscd", "version": "1.0.2", "author": "ghoneycutt", "summary": "manage NSCD - name service cache daemon", "license": "Apache License, Version 2.0", "source": "git://github.com/ghoneycutt/puppet-module-nscd.git", "project_page": "https://github.com/ghoneycutt/puppet-module-nscd", "issues_url": "https://github.com/ghoneycutt/puppet-module-nscd/issues", "description": "Manage every aspect of NSCD - name service cache daemon", "dependencies": [ {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"} ]}

© 2014 GH Solutions, LLC

Page 10: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

SkeletonProvides a template for generating new modules

https://github.com/ghoneycutt/puppet-module-skeleton

$ git clone https://github.com/ghoneycutt/puppet-module-skeleton$ VARDIR=`puppet config print vardir`$ mkdir -p $VARDIR/puppet-module/skeleton/$ rsync -avp --exclude .git puppet-module-skeleton/ \ $VARDIR/puppet-module/skeleton/

© 2014 GH Solutions, LLC

Page 11: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Generate a module$ cd /etc/puppet/modules$ puppet module generate <forgename>-<modulename>$ mv <forgename-modulename> <modulename>

© 2014 GH Solutions, LLC

Page 12: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Componentsghoneycutt-motdghoneycutt-motd/.fixtures.ymlghoneycutt-motd/.gitignoreghoneycutt-motd/.travis.ymlghoneycutt-motd/Gemfileghoneycutt-motd/LICENSEghoneycutt-motd/Modulefileghoneycutt-motd/README.mdghoneycutt-motd/Rakefileghoneycutt-motd/manifestsghoneycutt-motd/manifests/init.ppghoneycutt-motd/specghoneycutt-motd/spec/classesghoneycutt-motd/spec/classes/init_spec.rbghoneycutt-motd/spec/fixturesghoneycutt-motd/spec/fixtures/manifestsghoneycutt-motd/spec/fixtures/manifests/site.ppghoneycutt-motd/spec/fixtures/modulesghoneycutt-motd/spec/spec_helper.rbghoneycutt-motd/testsghoneycutt-motd/tests/init.pp

Page 13: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

In the beginning© 2014 GH Solutions, LLC

Page 14: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

In the beginning...Things were simple. We stuck all of our modules into one repo.Luke told me it was a good idea and we spent time puppetizing

the setup.© 2014 GH Solutions, LLC

Page 15: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

In the beginning...That was 2008.

© 2014 GH Solutions, LLC

Page 16: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

There are better ways!© 2014 GH Solutions, LLC

Page 17: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Looking backEveryone has to be on the same release cycle or you get

dependency issues.© 2014 GH Solutions, LLC

Page 18: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

ScaleThis scales to one organization with one release cycle who are

not concerned with others using their code.© 2014 GH Solutions, LLC

Page 19: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Pro'sEasy to get started

© 2014 GH Solutions, LLC

Page 20: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Con'sEverything is released at the same time

Promotes forking

Merge hell© 2014 GH Solutions, LLC

Page 21: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

AnalysisAvoid at all costs.

Separate repo for each module© 2014 GH Solutions, LLC

Page 22: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Puppetfile© 2014 GH Solutions, LLC

Page 23: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

PuppetfileSimple file that lists your modules, where to get them, and at what version.

# git repomod 'nscd', :git => 'git://github.com/ghoneycutt/puppet-module-nscd.git', :ref => 'v1.0.0'

© 2014 GH Solutions, LLC

Page 24: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

PuppetfileAlso supports the Puppet Forge

# puppet forgeforge 'https://forgeapi.puppetlabs.com'mod 'puppetlabs/stdlib', '4.2.1'

© 2014 GH Solutions, LLC

Page 25: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

PuppetfileCan be validated and kept under revision control.

ruby -c Puppetfile© 2014 GH Solutions, LLC

Page 26: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

ghoneycutt's puppet-moduleshttps://github.com/ghoneycutt/puppet-modules

All of the modules and their dependencies that I write, use, and support.

apache inittab pam rubyapt localization passenger selinuxcommon make pe_gem sshconcat motd portage stdlibdnsclient mysql postgresql sysklogdfacter network puppet timezonefirewall nfs puppetdb typesgcc nisclient r10k utilsgit nrpe rancid vcsrepohosts nscd redhat vimhtpasswd nsswitch rpcbind wgetinifile ntp rsyslog xinetd

© 2014 GH Solutions, LLC

Page 27: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

modulepath© 2014 GH Solutions, LLC

Page 28: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Puppet < 3.6Search path for modules

modulepath = /etc/puppet/environments/$environment/modules:/etc/puppet/modules

© 2014 GH Solutions, LLC

Page 29: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Puppet >= 3.6modulepath is deprecated

Warning: Setting modulepath is deprecated in puppet.conf. Seehttp://links.puppetlabs.com/env-settings-deprecations (at/usr/lib/ruby/site_ruby/1.8/puppet/settings.rb:1095:in`issue_deprecations')

© 2014 GH Solutions, LLC

Page 30: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Puppet >= 3.6environmentpath = /etc/puppet/environmentsbasemodulepath = /etc/puppet/modules

© 2014 GH Solutions, LLC

Page 31: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

environmentpathA search path for directory environments. Under $environmentpath are directories for each

$environment and under those are modules and manifests.

/etc/puppet/environments├── dev│ ├── manifests│ │ └── site.pp│ └── modules│ ├── apache│ ├── ...│ └── zookeeper├── fix_it│ ├── manifests│ │ └── site.pp│ └── modules│ ├── apache│ ├── ...│ └── zookeeper└── production ├── manifests │ └── site.pp └── modules ├── apache ├── ... └── zookeeper

© 2014 GH Solutions, LLC

Page 32: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

basemodulepathSearch path for global modules. This is essentially appended to the modulepath.

basemodulepath = /var/local/ghoneycutt-modules© 2014 GH Solutions, LLC

Page 33: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Puppet Forge© 2014 GH Solutions, LLC

Page 34: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Managed by RyanColeman

@ryanycoleman

Page 35: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Puppet ForgeRepo of puppet modules with dependency tracking.

© 2014 GH Solutions, LLC

Page 36: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
Page 37: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Puppet Forge -- Demo Time

search

# puppet module search openstackinstall

# puppet module install puppetlabs-openstack© 2014 GH Solutions, LLC

Page 38: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Search by metadata

© 2014 GH Solutions, LLC

Page 39: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Pro'sGreat way to find new modules

Can filter by OS and Puppet version

Can install from command line

Resolves dependencies© 2014 GH Solutions, LLC

Page 40: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Con'sInstalling from the command line leavesyou without something to track inversion control.

Resolving dependencies based onmodules' metadata can be troublesome.

© 2014 GH Solutions, LLC

Page 41: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

AnalysisUse the forge to find modules

Install from the command line whendeveloping to make note of yourdependencies

Potentially use forge in your Puppetfile© 2014 GH Solutions, LLC

Page 42: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

librarian-puppet© 2014 GH Solutions, LLC

Page 43: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Written by Tim Sharpe@rodjek

© 2014 GH Solutions, LLC

Page 44: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

librarian-puppetIterates through Puppetfile and recursively solves dependencies

for you.© 2014 GH Solutions, LLC

Page 45: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Installation# sudo gem install -V librarian-puppet

Usage# cd /path/to/dir_with_Puppetfile# librarian-puppet install -v

© 2014 GH Solutions, LLC

Page 46: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Pro'sUses a Puppetfile, so you havesomething in version control

Handles dependencies© 2014 GH Solutions, LLC

Page 47: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Con'sHandles dependencies - this is anightmare with a large set of diversemodules

© 2014 GH Solutions, LLC

Page 48: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

AnalysisAfter experiencing a lot of frustration with the dependency

management, I gave up on this and moved to librarian-puppet-simple. Big props to Tim for writing this and Puppetfile which has

became a standard.© 2014 GH Solutions, LLC

Page 49: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

librarian-puppet-simple© 2014 GH Solutions, LLC

Page 50: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Written by Dan Bode@bodepd

© 2014 GH Solutions, LLC

Page 51: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

librarian-puppet-simpleIterates through Puppetfile without any dependency management.

© 2014 GH Solutions, LLC

Page 52: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Installation# sudo gem install -V librarian-puppet-simple

UsageSimilar to librarian-puppet

# cd /path/to/dir_with_Puppetfile# librarian-puppet install -v

© 2014 GH Solutions, LLC

Page 53: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Pro'sNo dependency management

Uses a Puppetfile, so you havesomething in version control

© 2014 GH Solutions, LLC

Page 54: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Con's..nope..

© 2014 GH Solutions, LLC

Page 55: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

AnalysisDan is my hero. After becoming frustrated with librarian-puppet'sdependency management, this tool simply iterates over a list of

modules, which is awesomely simple.© 2014 GH Solutions, LLC

Page 56: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

r10k© 2014 GH Solutions, LLC

Page 57: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Written by Adrien Thebo@nullfinch

© 2014 GH Solutions, LLC

Page 58: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

r10kCreates an environment for every branch in your puppet-modules

git repo.© 2014 GH Solutions, LLC

Page 59: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

InstallationThere's a module for that https://github.com/acidprime/r10k

© 2014 GH Solutions, LLC

Page 60: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Work flow[foo@laptop]# git checkout -b fixit \ vi Puppetfile \ ruby -c Puppetfile \ git commit -a \ git push origin fixit[root@puppet]# r10k deploy environment -vp && \ service httpd graceful

© 2014 GH Solutions, LLC

Page 61: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Automate deploy step with ssh keys# Hiera entry using ghoneycutt/sshssh::keys: r10k: ensure: 'present' user: 'root' type: 'rsa' key: 'AAAAB3Nz....' options: 'command="/usr/bin/r10k deploy environment -vp \ && /sbin/service httpd graceful"'# ~/.ssh/config on your workstationHost r10k User root Hostname puppet.example.com IdentityFile /Users/gh/.ssh/r10k

[foo@laptop]# ssh r10k© 2014 GH Solutions, LLC

Page 62: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Add a rake task

# Rakefiletask :deploy do sh 'ssh r10k'end[foo@laptop]# rake deploy

© 2014 GH Solutions, LLC

Page 63: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

MCollectiveinclude r10k::mcollective from acidprime/r10k

[foo@laptop]$ mco r10k synchronize© 2014 GH Solutions, LLC

Page 64: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Pro'sMake's it really easy to do development

Do not need access to the puppetmaster

Uses a Puppetfile, so you havesomething in version control

© 2014 GH Solutions, LLC

Page 65: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Con's..nope..

You need a centralized git repo, which hopefully you already have:)

© 2014 GH Solutions, LLC

Page 66: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

AnalysisThebo is my hero, r10k provides an easy work flow for developersto make changes in their environment all without shell access on

the puppet master.© 2014 GH Solutions, LLC

Page 67: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Continued Learning© 2014 GH Solutions, LLC

Page 68: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Continued LearningPuppet modules

Use my modules https://github.com/ghoneycutt/puppet-modulesand send me pull requests.

© 2014 GH Solutions, LLC

Page 69: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Continued LearningRuby

Follow facter and submit pull requests.© 2014 GH Solutions, LLC

Page 70: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Continued LearningAsk and Solve Puppet questions

https://ask.puppetlabs.com - Recommend the weekly digest.© 2014 GH Solutions, LLC

Page 71: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Continued LearningPuppet modules

Use my modules https://github.com/ghoneycutt/puppet-modulesand send me pull requests.

Ruby

Follow facter and submit pull requests.

Ask and Solve Puppet questions

https://ask.puppetlabs.com - Recommend the weekly digest.© 2014 GH Solutions, LLC

Page 72: 2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle

Multiple approaches tomanaging your Puppet

modulesPuppet Camp Seattle

2014-11-11

Seattle, WA

LearnPuppet.comGarrett Honeycutt

[email protected]@learnpuppet