Skip to content

Instantly share code, notes, and snippets.

@richardc
Last active December 19, 2015 04:39
Show Gist options
  • Select an option

  • Save richardc/5899089 to your computer and use it in GitHub Desktop.

Select an option

Save richardc/5899089 to your computer and use it in GitHub Desktop.

datacat implementation of nagios configuration

These are exported resources for great justice. The intent here is that you can multiply declare the same service and just generate one service definition - this is a usecase of the #puppet user watchman_.

http://richardc.unixbeard.net/2013/02/puppet-concat-patterns/ for more context

class nagios {
datacat { '/etc/nagios/objects/services.cfg':
template => 'nagios/services.cfg.erb',
}
Datacat_fragment <| tag = 'nagios' |>
}
class role::linux_host {
nagios::service { "ping":
check_command => '$USER1$/check_ping -h $HOST$',
}
}
define nagios::service ($check_command) {
@@datacat_fragment { "nagios::service ${name} from ${fqdn}":
tag => 'nagios',
target => '/etc/nagios/objects/services.cfg',
data => {
$name => {
check_command => $check_command,
},
},
}
}
<% @data.keys.sort.each do |service| %>
define service {
name <%= service %>
<% @data[service].keys.sort.each do |field| %>
<%= field %> <%= @data[service][field] %>
}
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment