Skip to content

An empty template for creating Puppet modules, including rspec, syntax, and lint checking as well as rvm/bundler support.

License

Notifications You must be signed in to change notification settings

stjeanp/puppet_module_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

####Table of Contents

  1. Overview
  2. Setup - What needs to be edited, changed, and configured
  3. Manifests
  4. Rspec Tests

##Overview

This is a stub that can be used to create a Puppet module. It includes basic support for building and testing using an rvm environment, which includes CI tools such as Jenkins or Travis. The rakefile includes support for rspec, lint, and syntax tests. It also includes the files needed to release the module to the Puppet Forge.

##Setup

While the files are in place, they are either in an unconfigured state or have dummy data in them. They will need to be edited to make them actually usable. Instructions are included below.

###.fixtures.yml

The .fixtures.yml file is a helper file used by the puppetlabs_spec_helper gem to make it easier to tell rspec where to find the module, as well as any modules from the forge or git repos. This is a part of the rspec test framework discussed below. Replace module_name with your module's name and add any module dependencies. Full documentation is at https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures

###.gitignore

The files that you want git to ignore. Change this to suit your environment.

###Gemfile

The Gemfile is used to tell bundler which gems the module need to have installed in the ruby environment. It is configured to support a basic module with basic dependencies. If you need to add more gems, this is where to do it. It is vital that this be kept in sync with your module's needs if you are going to develop under rvm based ruby environments or if you are going to use a CI tool such as Jenkins or Travis. More information on the Gemfile can be found at http://bundler.io/man/gemfile.5.html

###metadata.json

The metadata.json file is used by the Puppet Forge to generate the module's page when it is published. Edit the file, replace the Changeme items with your own information, set the version number, update the dependencies, supported operating systems and versions, and requirements to suit your environment. Full documentation for the metadata.json file is found at https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file

###Rakefile

The Rakefile is ready to use as is. To run all tests, including syntax validation, linting, and rspec tests, just run "rake test". If you want to include syntax checking of hiera data, uncomment the relevant line and update the paths as needed.

##Manifests

The "manifests" directory is where you place your Puppet classes, following the best practices and instructions at https://docs.puppetlabs.com/pe/latest/quick_writing_nix.html

##Rspec Tests

The spec directory is where your rspec tests live. There is a stub in the "spec/classes" directory to get you started. If you need to use hiera data, it should be put in the "fixtures/hiera" directory. The hiera.yaml file in there is configured to load hiera data based on the "testname" fact, which can be set in your test files. See the documentation at http://rspec-puppet.com for more information.

About

An empty template for creating Puppet modules, including rspec, syntax, and lint checking as well as rvm/bundler support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published