diff options
Diffstat (limited to 'puppet/modules')
-rw-r--r-- | puppet/modules/site_nagios/manifests/add_host.pp | 30 | ||||
-rw-r--r-- | puppet/modules/site_nagios/manifests/add_service.pp | 22 | ||||
-rw-r--r-- | puppet/modules/site_nagios/manifests/server.pp | 17 |
3 files changed, 66 insertions, 3 deletions
diff --git a/puppet/modules/site_nagios/manifests/add_host.pp b/puppet/modules/site_nagios/manifests/add_host.pp new file mode 100644 index 00000000..5148048d --- /dev/null +++ b/puppet/modules/site_nagios/manifests/add_host.pp @@ -0,0 +1,30 @@ +define site_nagios::add_host ($ip, $services='' ) { + + $nagios_hostname = $name + + #notice ("$nagios_hostname $ip $services") + + nagios_host { $nagios_hostname: + address => $ip, + use => 'generic-host', + } + + # turn serice array into hash + # https://github.com/ashak/puppet-resource-looping + $nagios_service_hashpart = { + 'host' => $nagios_hostname, + 'ip' => $ip, + } + $dynamic_parameters = { + 'service' => '%s' + } + + #$nagios_services = ['one', 'two'] + $nagios_servicename = "${nagios_hostname}_%s" + + $nagios_service_hash = create_resources_hash_from($nagios_servicename, $services, $nagios_service_hashpart, $dynamic_parameters) + #notice ($created_resource_hash) + + + create_resources ( site_nagios::add_service, $nagios_service_hash ) +} diff --git a/puppet/modules/site_nagios/manifests/add_service.pp b/puppet/modules/site_nagios/manifests/add_service.pp new file mode 100644 index 00000000..5a5b344f --- /dev/null +++ b/puppet/modules/site_nagios/manifests/add_service.pp @@ -0,0 +1,22 @@ +define site_nagios::add_service ($host, $ip, $service) { + + notice ('$name $host $ip $service') + + case $service { + 'openvpn': { + $check_command = 'check_openvpn!...' + $service_description = 'Openvpn' + } + 'webapp': { + $check_command = 'check_http!...' + $service_description = 'Website' + } + default: { fail ('unknown service') } + } + + nagios_service { $name: + use => 'generic-service', + check_command => $check_command, + service_description => $service_description, + host_name => $host } +} diff --git a/puppet/modules/site_nagios/manifests/server.pp b/puppet/modules/site_nagios/manifests/server.pp index e11ffd48..df3e00cd 100644 --- a/puppet/modules/site_nagios/manifests/server.pp +++ b/puppet/modules/site_nagios/manifests/server.pp @@ -1,7 +1,18 @@ class site_nagios::server { - class {'nagios': - allow_external_cmd => true + + $nagios_hiera=hiera('nagios') + $nagiosadmin_pw = $nagios_hiera['nagiosadmin_pw'] + $hosts = $nagios_hiera['hosts'] + + include nagios::defaults + include nagios::base + #Class ['nagios'] -> Class ['nagios::defaults'] + class {'nagios::apache': + allow_external_cmd => true, + stored_config => false, + #before => Class ['nagios::defaults'] } - #include nagios::defaults + + create_resources ( site_nagios::add_host, $hosts) } |