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:
include_recipe 'logwatch' cookbook_file '/etc/logwatch/scripts/services/restart' do owner 'root' group 'root' mode 0755 end cookbook_file '/etc/logwatch/conf/services/restart.conf' do owner 'root' group 'root' mode 0644 end cookbook_file '/etc/logwatch/conf/logfiles/restart_logs.conf' do owner 'root' group 'root' mode 0644 end
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.