Thismoduleinstallsandconfiguresthe[Icinga2monitoringsystem](https://www.icinga.org/icinga2/). It can also install and configure [NRPE](http://exchange.nagios.org/directory/Addons/Monitoring-Agents/NRPE--2D-Nagios-Remote-Plugin-Executor/details) on client systems that are being monitored by an Icinga 2 server.
OnEL-basedsystems(CentOS,RedHatEnterpriseLinux,Fedora,etc.),the[EPELpackagerepository](https://fedoraproject.org/wiki/EPEL) is required.
Ifyouwouldliketousethe`icinga2::object`definedtypesas[exportedresources](https://docs.puppetlabs.com/guides/exported_resources.html), you'll need to have your Puppet master set up with PuppetDB. See the Puppet Labs documentation for more info: [Docs: PuppetDB](https://docs.puppetlabs.com/puppetdb/)
###Serverrequirements
Icinga2requireseithera[MySQL](http://www.mysql.com/) or a [Postgres](http://www.postgresql.org/) database.
Ifyouwouldliketosetupyourowndatabase,eitherofthePuppetLabs[MySQL](https://github.com/puppetlabs/puppetlabs-mysql) or [Postgres](https://github.com/puppetlabs/puppetlabs-postgresql) modules can be used.
Theexamplebelowshowsthe[PuppetLabsPostgresmodule](https://github.com/puppetlabs/puppetlabs-postgresql) being used to install Postgres and create a database and database user for Icinga 2:
Forproductionuse,you'llprobablywanttogetthedatabasepasswordviaa[Hieralookup](http://docs.puppetlabs.com/hiera/1/puppet.html) so the password isn't sitting in your site manifests in plain text.
**Note:**Forproductionuse,you'llprobablywanttogetthedatabasepasswordviaa[Hieralookup](http://docs.puppetlabs.com/hiera/1/puppet.html) so the password isn't sitting in your site manifests in plain text:
Nodesthatarebeingmonitoredcanhavethe`@@` virtual resources applied to them:
<pre>
@@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"
}
</pre>
Then, on your Icinga 2 server, you can collect the exported virtual resources (notice the camel casing in the class name):
<pre>
#Collect all @@icinga2::object::host resources from PuppetDB that were exported by other machines:
Icinga2::Object::Host <<| |>> { }
</pre>
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:
**However**,thisdoesn'tmeanthatthevaluesareundefinedinIcinga2.Icinga2itselfhasbuilt-indefaultvaluesformanyobjectparametersandfallsbacktothemifoneisn'tpresentinanobjectdefinition.Seethedocsforindividualobjecttypesin[ConfiguringIcinga2](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.
IfyouwouldliketousePuppetorFactervariablesinan`assign_where`or`ignore_where`parameter'svalue,you'llfirstneedtodouble-quotethewholevaluefor[Puppet'svariableinterpolation](http://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#double-quoted-strings) to work. Then, you'll need to escape the double quotes that surround the Icinga 2 string literals inside:
<pre>
assign_where=>"\"linux_servers\" in host.${facter_variable}"",
</pre>
####[`icinga2::object::host`](id:object_host)
This defined type creates host objects.
Example:
<pre>
@@icinga2::object::host { $::fqdn:
display_name => $::fqdn,
ipv4_address => $::ipaddress_eth1,
groups => ["linux_servers", 'mysql_servers', 'postgres_servers', 'clients', 'smtp_servers', 'ssh_servers', 'http_servers', 'imap_servers'],
vars => {
os => 'linux',
virtual_machine => 'true',
distro => $::operatingsystem,
},
target_dir => '/etc/icinga2/objects/hosts',
target_file_name => "${fqdn}.conf"
}
</pre>
Notesonspecificparameters:
*`groups`:mustbespecifiedasa[Puppetarray](https://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#arrays), even if there's only one element
*`vars`:mustbespecifiedasa[Puppethash](https://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#hashes), with the Icinga 2 variable as the **key** and the variable's value as the **value**