developing a role for collectd

tl;dr - What's the best way (if there is one) to develop a general
purpose re-usable role for something that's seems infinitely
configurable ?

I'm working on developing a role for collectd, hopefully something
that is useful enough to be published to ansible-galaxy.

collectd is a tool used to gather system/app metrics from many
endpoints, and forward them on to somewhere else or write them to
disk.

For each kind of metric in collectd exists its own specific
configuration. Luckily the product has a /etc/collectd.d/ directory,
so you can have a disk.conf, apache.conf, memory.conf, myapp.conf,
etc.

I can think of two different ways to model collect into roles --

Option 1 -- Roles and Dependent Roles

Have one common role call collectd-common -- this would install the
package, setup the service, and set up a very basic configuration
file.

All other configuration is done through roles that depend on
collectd-common. These dependent roles would likely not make it on
ansible-galaxy since they could be too site-specific. For example:
collectd-myapp, collectd-mysystem, etc.

I think if there was a sub-role for every different plugin (20+ in
total), then things are going to get very role sprawly.

Option 2 -- One Big Role

Have one collectd role that installs collectd but is aware of all the
various collectd plugins that are available -- it has templates for
each one --, and you simply tell it which plugins you'd like to
activate and which variables are going to be used to configure those
templates.

This would require quite a big chunk of complex vars, and lots of
template logic.

Thanks!

- James

What I generally do:

  • Have a conf.d folder where other roles can drop config which they need
  • Have these said roles drop configs of their own in that said folder

Then make sure that roles are run in proper order. We have a couple of things here which we run like this (firewall, collectd, nginx, etc), and it has been working pretty well so far.