diff --git a/README.md b/README.md index 582db76..4e0c69b 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,65 @@ class { 'icinga2::server': This will stop the `icinga2::server` class from trying to install the plugins pacakges, since the `icinga2::nrpe` class will already be installing them and will prevent a resulting duplicate resource error. +###Object type usage + +This module includes several defined types that can be used to automatically generate Icinga 2 format object definitions. They function in a similar way to [the built-in Nagios types that are included in Puppet](http://docs.puppetlabs.com/guides/exported_resources.html#exported-resources-with-nagios). + +####Exported resources + +Like the built-in Nagios types, they can be exported to PuppetDB as virtual resources and collected on your Icinga 2 server. + +Nodes that are being monitored can have the `@@` virtual resources applied to them: + +
+@@icinga2::object::host { $::fqdn:
+  display_name => $::fqdn,
+  ipv4_address => $::ipaddress_eth0,
+  groups => ['linux_servers', 'mysql_servers'],
+  vars => {
+    os              => 'linux',
+    virtual_machine => 'true',
+    distro          => $::operatingsystem,
+  },
+  target_dir => '/etc/icinga2/objects/hosts',
+  target_file_name => "${fqdn}.conf"
+}
+
+ +Then, on your Icinga 2 server, you can collect the exported virtual resources (notice the camel casing in the class name): + +
+#Collect all @@icinga2::object::host resources from PuppetDB that were exported by other machines:
+Icinga2::Object::Host <<| |>> { }
+
+ +Unlike the built-in Nagios types, the file owner, group and mode of the automatically generated files can be controlled via the `target_file_owner`, `target_file_group` and `target_file_mode` parameters: + +
+@@icinga2::object::host { $::fqdn:
+  display_name => $::fqdn,
+  ipv4_address => $::ipaddress_eth0,
+  groups => ['linux_servers', 'mysql_servers'],
+  vars => {
+    os              => 'linux',
+    virtual_machine => 'true',
+    distro          => $::operatingsystem,
+  },
+  target_dir        => '/etc/icinga2/objects/hosts',
+  target_file_name  => "${fqdn}.conf"
+  target_file_owner => 'root',
+  target_file_group => 'root',
+  target_file_mode  => '644'
+}
+
+ +####`undef` and default object values + +Most of the object parameters *in the Puppet module* are set to **undef**. + +This means that they will not be added to the rendered object definition files. + +**However**, this doesn't mean that the values are undefined in Icinga 2. Icinga 2 itself has built-in default values for many object parameters and falls back to them if one isn't present in an object definition. See the docs for individual object types in [Configuring Icinga 2](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2) for more info about which object parameters have what default values. [Reference](id:reference) ---------