From 5ce282fdc842a6a3f9aa8bfc9fe58455f106a6ed Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Sat, 5 Jul 2014 18:12:36 -0700 Subject: [PATCH 1/2] Added an empty class file for icinga2::objects so that we can keep all of the object types in their own subclass and directory hierarchy. --- manifests/objects.pp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 manifests/objects.pp diff --git a/manifests/objects.pp b/manifests/objects.pp new file mode 100644 index 0000000..50ce4b9 --- /dev/null +++ b/manifests/objects.pp @@ -0,0 +1,11 @@ +# == Class: icinga2::params +# +# This class is purposefully empty. It just serves as a container class for other +# icinga2::objects:: classes. +# +# === Parameters +# +# See the inline comments. +# + +class icinga2::objects { } \ No newline at end of file From 0437d4d69a75d69246a996d5a0f2d2b78cf65db7 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Wed, 9 Jul 2014 22:20:01 -0700 Subject: [PATCH 2/2] Added a basic defined type for Icinga 2 host objects; added an accompanying template. This is really basic now. I'll add more parameters to it later on. --- manifests/objects/host.pp | 29 +++++++++++++++++++ templates/object_host.conf.erb | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 manifests/objects/host.pp create mode 100644 templates/object_host.conf.erb diff --git a/manifests/objects/host.pp b/manifests/objects/host.pp new file mode 100644 index 0000000..0add4f7 --- /dev/null +++ b/manifests/objects/host.pp @@ -0,0 +1,29 @@ +# == Defined type: icinga2::object::host +# +# This defined type +# +# === Parameters +# +# See the inline comments. +# + +define icinga2::objects::host ( + $ipv4_address = $ipaddress_eth0, + $ipv6_address = $ipaddress_eth0, + $object_hostname = $name, + $display_name = $fqdn, + $template_to_import = 'generic-host', + $target_dir = '/etc/icinga2/conf.d', + $target_file_name = "${fqdn}.conf", +) { + + file {"${target_dir}/${target_file_name}": + ensure => file, + owner => 'root', + group => 'root', + mode => '644', + content => template('icinga2/object_host.conf.erb'), + notify => Service['icinga2'], + } + +} \ No newline at end of file diff --git a/templates/object_host.conf.erb b/templates/object_host.conf.erb new file mode 100644 index 0000000..3eb9ee5 --- /dev/null +++ b/templates/object_host.conf.erb @@ -0,0 +1,51 @@ +/** + * WARNING: This host definition is automatically generated by Puppet. + * ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN! + */ + +/** + * A host definition. You can create your own configuration files + * in the conf.d directory (e.g. one per host). By default all *.conf + * files in this directory are included. + * + */ + +//Parameters to include: +// * displayname +// * address +// * address6 +// * groups +// * vars +// * check_command +// * max_check_attempts +// * check_period +// * check_interval +// * retry_interval +// * enable_notifications +// * enable_active_checks +// * enable_passive_checks +// * enable_event_handler +// * enable_flap_detection +// * enable_perfdata +// * event_command +// * flapping_threshold +// * volatile +// * notes +// * notes_url +// * action_url +// * icon_image +// * icon_image_alt + +object Host "<%= @object_hostname %>" { + <%#- If any of the @ parameters are undefined, don't print anything for them: -%> + <%- if @template_to_import -%> + <%#- Otherwise, include the parameter: -%> + import "<%= @template_to_import -%>" + <%- end -%> + <%- if @display_name -%> + display_name = "<%= @display_name -%>" + <%- end -%> + <%- if @ipv4_address -%> + address = "<%= @ipv4_address -%>" + <%- end -%> +}