ottawa puppet user group - publishing a module on the puppet forge

18

Click here to load reader

Upload: bill-fraser

Post on 02-Jul-2015

48 views

Category:

Technology


0 download

DESCRIPTION

A presentation delivered at the February 2014 meeting of the Ottawa Puppet User Group, discussing why you would want to publish a module to the Puppet Forge, and some best practices for module development.

TRANSCRIPT

Page 1: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Publishing A Module On The Puppet Forge

An introduction to packaging your module and sharing it with the community

Bill Fraser

February 25, 2014

Page 2: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Agenda

• Introduction • Why you should publish your module • What is a module, anyway? • Managing configuration with style! • Continuous integration • Next steps • Q & A

2 © 2014 Pythian

Page 3: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Introduction

3 © 2014 Pythian

Page 4: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Why Publish A Module?

• Major strength of Puppet • Over 2000 modules • Integration via Puppet Module Tool • Metadata (version, release date, downloads) • Searchable • Documentation (requirements, parameters, usage) • Giving back to the community

4 © 2014 Pythian

Page 5: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Truth In Advertising

• Documentation exists • Adheres to best practice • Dependency resolution • Semantic versioning • Automated test and build

5 © 2014 Pythian

Page 6: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

What Is A Module?

1. Identify Problem 2. Solve Problem 3. ??? 4. Profit!

6 © 2014 Pythian

Page 7: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

What Is A Module? /etc/puppet/modules/widget/manifests/init.pp

7 © 2014 Pythian

Page 8: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

What Is A Module?

• widget – Top-level matches the name of the module – manifests/ – All of the manifests for the module

• init.pp – Main class definition for the module • doodad.pp – Class named widget::doodad

– files/ – Location for static files – lib/ – Contains plugins, custom facts / resources – templates/ – Contains templates – tests/ – Examples of how to declare classes / types – spec/ – Contains spec tests

8 © 2014 Pythian

Page 9: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

puppet module generate • Modulefile

– Module metadata – Dependency information

9 © 2014 Pythian

• README • spec_helper.rb

Page 10: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Managing Configuration With Style!

• “Just because you can, doesn’t mean you should” • By Conforming to the style guide, you ensure that

– You follow best practice in module design and style – Your module is readable and therefore easier to maintain – Your module will work with an ENC without requiring one – You do not inherit or declare other classes unless you need to

• puppet-lint is your friend!

10 © 2014 Pythian

Page 11: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

puppet-lint

• Install puppet-lint

11 © 2014 Pythian

• Run puppet-lint

• But wait, let’s make it more awesome!

Page 12: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

puppet-lint • Gemfile

12 © 2014 Pythian

• Rakefile

Page 13: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Continuous Integration

• Automatic testing against multiple Ruby and / or Puppet versions

• Travis CI and GitHub – Sign in through GitHub OAuth and grant read and

write access to GitHub – Activate GitHub service hooks – Add .travis.yml to your module repository – Validate your .travis.yml file with travis-lint – Trigger a build

13 © 2014 Pythian

Page 14: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Continuous Integration Add .travis.yml to your module repository

14 © 2014 Pythian

Page 15: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Continuous Integration

15 © 2014 Pythian

Page 16: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Next Steps

• Test Driven Development (TDD) • Behaviour Driven Development (BDD) • rspec-puppet • rspec-system

16 © 2014 Pythian

Page 17: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

References • Puppet Forge: http://forge.puppetlabs.com/ • Style Guide: http://docs.puppetlabs.com/guides/style_guide.html • Publishing Modules on the Puppet Forge:

http://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html • puppet-lint: http://puppet-lint.com/ • Travis CI: https://travis-ci.org/ • Pro Puppet, Second Edition: http://www.apress.com/9781430260400 • GDash Module

– Puppet Forge: http://forge.puppetlabs.com/bfraser/gdash – GitHub: https://github.com/bfraser/puppet-gdash

17 © 2014 Pythian

Page 18: Ottawa Puppet User Group - Publishing a Module on the Puppet Forge

Questions?

Thank you!

Bill Fraser [email protected]

18 © 2014 Pythian