Hi,
I'm using Puppet for the first time, and for my tests, I'm recreating our Nagios setup into a Puppet modules. It works at 95%, but I do have a problem: my module include files but I also need to modify a couple of Nagios configuration files that comes with the Nagios RPM package. Example:
commandes.pp:
class nagios::commandes {
nagios_command { 'process-service-perfdata':
command_name => 'process-service-perfdata',
ensure => present,
target => '/etc/nagios/objects/commands.cfg',
}
}
init.pp:
class nagios {
include nagios::commandes
package { 'nagios':
ensure => present,
}
package { 'nagios-plugins-all':
ensure => present,
}
package { 'nrpe':
ensure => present,
}
service { 'nagios':
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Package["nagios"],
}
}
It works fine when Nagios is already installed, but if not, the include of the class in init.pp is done before the package is installed so it fails.
Error: Puppet::Util::FileType::FileTypeFlat could not write /etc/nagios/objects/commands.cfg: No such file or directory - /etc/nagios/objects/commands.cfg
Error: /Stage[main]/Nagios::Commandes/Nagios_command[process-service-perfdata]: Could not evaluate: Puppet::Util::FileType::FileTypeFlat could not write /etc/nagios/objects/commands.cfg: No such file or directory - /etc/nagios/objects/commands.cfg
If there a way to include the class only if the package is installed?