Extending logwatch with Chef

If you saw my previous post on Extending Logwatch, it may have occurred to you that even something as simple as manually creating three small files and saving them to the (different) correct locations with the right owners and permissions is rife with error.  Here we basically assume that anything you do manually will get screwed up, and we are seldom disappointed.

On the other hand, if you are already using Chef to deploy or manage servers, you may have realized what a nice little recipe this would be.

We did create a Chef cookbook for this task, and published it here https://github.com/flatrocks/restart-watch as an example of a simple and useful Chef application.  Here are the guts of the default recipe:

It simply:

  • Ensures that the basic logwatch recipe is included (to install logwatch,) and
  • Copies the three files required to create the service.   The three files that get copied are saved in the cookbook and are under version control along with the rest of the recipe. 

We have not automated everything yet, but we’re working on it, and small steps like this are paying off quickly.