Getting started
This document is a quick intro for getting started with configuring a node using Puppet.
Note that all our Puppet code is now consolidated in a monorepo.
Creating the module
There are three types of Puppet modules in use. We are going to create a profile module, which is a module that describes the configuration for a node.
To help you getting started, we have a template module. Assuming you are in the root directory of your checkout of the Puppet repository, start by coping the template module and renaming it:
$ cd modules
$ cp -r pmodule_template pmodule_new_module
$ cd pmodule_new_module
$ sed -i 's/pmodule_template/pmodule_new_module/g' $(find . -type f)
# for mac OS X
$ sed -i '' -e 's/pmodule_template/pmodule_letsencrypt/g' $(find . -type f)
You should also update README.md
to describe the function of your module
Adding a role for your new module
Roles are used to describe the full configuration of a node. Our roles typically inherit from the default server role and then include the profile module that describes the configuration of the node. This way, all our servers are mostly similar.
Roles are located in the modules/pmodule_role/manifests
directory. Create a new file here describing your role:
$ nano modules/pmodule_role/manifests/new_module.pp
It will typically look something like this:
class pmodule_role::new_module inherits pmodule_role::server {
include pmodule_new_module
}
Note that the class name (pmodule_role::new_module
) must match the file name (new_module.pp
).
Assigning the role to a node
Once the new role is merged into master, it is time to assign the role to the node. This is done using Hiera, which is a built-in key-value configuration data lookup system in Puppet. All hiera data is found under the hieradata
directory.
Create a configuration file for the node:
$ nano hieradata/nodes/vltrd123.cn.uninett.no.yaml
This file will typically look like this:
---
role: pmodule_role::new_module
Commit and push to a new branch
Once you have created your puppet code, commit it to Git and push it as a new branch:
$ git add .
$ git commit
$ git push origin HEAD:add_my_new_module
Then you can create a merge request for your branch.
Before merging your branch into master
we recommend:
- Test your changes first, see Testing your changes
- Tidy up your commits, see Git Workflow for tips