I have several processes running on servers with different roles that are monitored by monit. For example, say I have an Apache server and a DB server with MySQL. I have several monitrc files that can be dropped in to monit's configuration directory to monitor these processes. What's the most elegant way in chef to make sure the appropriate files get into the monit configuration directory, based on the role?
Options I see:
- use a template resource in a monit cookbook that checks the node's roles to see if it should be executing
- use a template resource in the apache and mysql cookbooks (but check to see if monit is installed somehow)
- Create separate recipies in the monit cookbook for each role, and add them to the run list for the role (monit::mysql, monit::apache, etc.)
What I'd really like to do is put the code for ensuring the files are moved in the role's file, but I don't think that's possible. Ideas?
Option 2 would be correct. It could be a cookbook_file also. Every package knows best about what aspect of it should be monitored. The same applies for logrotation also.