Skip to content
descala edited this page Oct 25, 2012 · 1 revision

Writing modules

You can create a redmine plugin to add a view to a puppet module. It will be used to configure parameters for your puppet module and pass them to the node through external_nodes.

take fail2ban module as an example, is a simple one with several comments.

Create skeleton files and directories:

rake initr:module:create name=test_module
  • This will create the test_module folder in initr/puppet/modules, and initr will automatically load it on next aplication start.
  • Structure of a module:
puppet/modules/
  app/
    controllers/
    models/
    views/
  db/
    migrate/
  files/
  manifests/
  templates/
  init.rb
  • As you can see it is a mix between a redmine plugin and a puppet module. The folder for puppet files are manifests, files and templates. For rails are app and db. File init.rb is used for plugin initialization.

Rails stuff

Model

Your model should inherit from Klass, and override some of its methods, the most important two are:

  • name: the name of the puppet class that your host will include
  • parameters: a hash of parameters that will be passed to host through external_nodes

Klass has a serialized attribute config to store parameters without modifying the database schema.

Controller and views

When you add a class to a node, configure action is called (unless you override configurable? method in your model) on your controller. Here you can make a view to configure parameters for your class.

Lib

The tipical Rails lib folder is called rails_lib on initr, since lib is used for puppet stuff

Puppet stuff

Manifests, files and templates

In manifests folder puppet will expect a file called init.pp. Make sure it defines a class that matches the return value of the name method of your model.

Lib

On lib folder you can add new facts and puppet functions, see base module for example