I have a puppet 3.8.5 environment that contains a module that installs an application on 3 servers in identical fashion.
In the module I have the following class
class app::monitoring {
include nrpe
include nagios::export
@@nagios_contactgroup:{ 'APP':
ensure => present,
alias => 'APP Developer',
members => 'user1, user2',
target => '/etc/nagios/conf.d/contacts.cfg',
}
@@nagios_contact {'user1':
ensure => present,
alias => 'user1',
email => '[email protected]',
service_notification_period => 'workhours',
host_notification_period => 'workhours',
service_notification_commands => 'notify-service-by-email',
host_notification_commands => 'notify-service-by-email',
target => '/etc/nagios/conf.d/contacts.cfg',
}
@@nagios_service { 'check_app_http_${fqdn}':
ensure => present,
use => "local-service',
host_name => $fqdn,
service_description => 'Check App - port 8000',
check_command => 'check_http_app!8000',
notifications_enabled => '1',
target => '/etc/nagios/conf.d/service.cfg',
}
@@nagios_command {"check_http_app":
ensure => present,
command_line => '/usr/lib64/nagios/plugins/check_http -H $HOSTADDRESS$ -p $ARG1$',
target => '/etc/nagios/conf.d/commands.cfg',
}
}
As expected all works correctly when puppet runs on each server, but fails with a duplicate entry error when puppet runs on the Nagios server. Is there a way to change the code so that if/when this is run on the subsequent servers I don't get a duplicate resource error?
At the moment I am manually creating the
- nagios_contactgroup,
- nagios_contact, and
- nagios_command
entries in /etc/nagios/objects so they effectively are hard coded into Nagios. I would prefer to have the ability to be able to completely rebuild nagios without human intervention.