-
Notifications
You must be signed in to change notification settings - Fork 4
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.
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
andtemplates
. For rails areapp
anddb
. Fileinit.rb
is used for plugin initialization.
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.
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.
The tipical Rails lib
folder is called rails_lib
on initr, since lib
is used for puppet stuff
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.
On lib
folder you can add new facts and puppet functions, see base module for example