I have the following resource:
exec{'regen-nagios-hosts':
command => '/usr/local/bin/generate-nagios-host-definitions-from-hostfile < /etc/hosts > /etc/nagios3/conf.d/sv-hosts.cfg',
user => 'root',
before => Class['nagios::server'],
notify => Service['nagios3'],
require => File['/etc/hosts'],
}
Ideally, I'd want to restart Nagios only if the file changed. It seems what I really want is a file resource, but file resources have a template or the actual content, not a script. How can I generate the file (or change my method) to restart Nagios only when /etc/nagios3/conf.d/sv-hosts.cfg
changes?
Best Answer
Assuming that each time your script runs it will generate the file exactly the same way for a given hosts file you could make a minor adjustment.
In the long term though it might be better to try and find ways to convert your script into a template. Or find some other way that fits better into the puppet way of doing things.