2. Hello
Me (then):
Student sysadmin at the IT department for
Portland State University’s College of Engineering
aka
The Computer Action Team (TheCAT)
github.com/pdxcat forge.puppetlabs.
com/pdxcat
4. What is a puppet module?
● An encapsulation of configuration for a
service
● A structure containing an organized set of
puppet code and data
● Analogous to a package, gem, python library
● The place where your code goes
5. What should a module do?
● Set up a service, such as:
○ ssh
○ mysql
○ apache
○ sudo
● Extend puppet functionality. Examples:
○ puppetlabs/stdlib
○ puppetlabs/concat
15. Drop in a configuration file
# files/sshd_config
# Managed by Puppet
# What ports, IPs and protocols we listen for
Port 22
Protocol 2
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
# ...
22. Templating strategies
# templates/sshd_config.erb
# Managed by Puppet
<% @ports.each do |port| %>
Port <%= port %>
<% end %>
<% @options.each do |k,v| %>
<%= k %> <%= v %>
<% end %>
31. Publishing your module
Changelog
## 2013-12-05 Release 0.10.0
### Summary:
This release adds FreeBSD osfamily support and various other improvements to some
mods.
### Features:
- Add suPHP_UserGroup directive to directory context
- Add support for ScriptAliasMatch directives
...
## 2013-09-06 Release 0.9.0
### Summary:
...
32. Publishing your module
README
● docs.puppetlabs.com/puppet/3/reference/READMEtemplate.markdown
34. Publishing your module
$ cd ssh/
$ puppet module build .
$ ls pkg/
cmurphy-ssh-0.0.1 cmurphy-ssh-0.0.1.tar.gz
35. Testing
Why we test:
● Testing gives us (some) assurance that our
code won’t break production systems
● Contributors can run tests without having
the same infrastructure as you
37. Testing your module
● Unit testing: rspec-puppet
○ rspec-puppet.com
$ bundle exec rake spec
38. Testing your module
# spec/classes/init_spec.rb
require 'spec_helper'
describe 'collectd' do
let :facts do
{:osfamily => 'RedHat'}
end
it { should contain_package('collectd').with(
:ensure => 'installed'
)}
it { should contain_service('collectd').with(
:ensure => 'running'
)}
# ...
40. Testing your module
# spec/acceptance/class_spec.rb
require 'spec_helper_acceptance'
case fact('osfamily')
# ...
describe 'ssh class' do
context 'default parameters' do
it 'should work with no errors' do
pp = "class { 'ssh': }"
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe service(servicename) do
it { should be_running }
end
# ...
43. Installing modules
Search for modules on forge.puppetlabs.com or
puppet module search ssh
Then install with
puppet module install saz/ssh
44. Where now?
Learn more at
docs.puppetlabs.com/guides/module_guides/bgtm.html
Get help at
Ask: ask.puppetlabs.com
IRC: #puppet on freenode
Mailing list: groups.google.com/group/puppet-users