A Look at Deploying an Icinga2 Server with Chef Cookbooks

The thought of deploying Icinga with Chef is an exciting prospect. You get all the benefits of the flexible monitoring Icinga provides with all the reliability and scalability of Chef’s configuration management. So, when I heard that Icinga had ditched their old monolithic cookbook design, I knew I needed to have a look.

What’s new?

Icinga has maintained a monolithic cookbook in the Chef Supermarket since 2014, but they’ve taken a big step forward toward manageability by breaking it up into four smaller cookbooks for easier management and customizability. Where once there was one, there are now four separate cookbooks for icinga2, icinga2repo, icinga2client, and icingaweb2.

Let’s walk through a deployment using these four Icinga 2 cookbooks to see what is required to set up a simple Icinga2 master with web interface.

Setting up the Cookbook

These Icinga cookbooks are fairly straightforward, although there are a few caveats to look out for. The current version of these cookbooks leave the creation of the databases to the user, so we will have to create them ourselves. This can be handled with a standard package/service block to install MariaDB and a few execute resources to set up a user for both Icinga2 and Icingaweb2.

Here’s an example installation cookbook:

an example installation cookbook

The default recipes do a good job of setting up everything you need in a fresh Icinga2 server install; however, they do not yet handle the configuration of the web interface. After deploying your cookbook to a node, you will need to visit <icinga-server-fqdn>/icingaweb2/setup to finish the installation.

Configuring the Web Interface

configuration of Icinga Web 2

In order to generate the setup token, you will need to run the following commands from your new Icinga2 master node, and then copy the node to the text box on the web interface.

commands from your new Icinga2 master node

What follows next is a standard setup configuration of the web interface, using the default settings that come with the cookbooks. Passwords and account names can be changed through the attributes file.

a standard setup configuration of the web interface, using the default settings that come with the cookbooks

These are the default configurations for the two databases set up by the Icinga2 and Icingaweb2 cookbooks. To allow these cookbooks to set up the schema for these databases, the following two attributes must be overridden:

Additionally, if you would like to use the API as your command transport option, you will need to push an API User Object with the correct credentials. This is shown below.

API User

In addition to the installation files, Icinga’s cookbooks also provide a number of useful LWRP resources for pushing Icinga2 configuration objects. The one shown above pushes the correct API user.

You can find a complete list of the Icinga2 LWRP here.

Final thoughts

Overall, the installation process is fairly straightforward. You can quickly get an Icinga server up and running with a wrapper cookbook and few lines of code. Moving forward, I hope the configuration of the web interface can be fleshed out and eventually automated.

In addition, it would be nice if the Icinga2 cookbook offered an option for an automatic database installation, though I can understand its exclusion in the name of flexibility.

Interested in learning more?

Shadow-Soft consultants regularly share ideas on our open source blog and at local meetups and events in Atlanta. Contact us if you’d like to talk about using Icinga and Chef together.

Todd Durning

Todd Durning works at Shadow-Soft, a Chef and Icinga partner that provides clients across North America with consulting, support, and training. An avid outdoorsman, Todd can often be found in a kayak or deep in the woods. When not outdoors, he enjoys solving games and puzzles. Incorporating these skillsets into his career, he solves complex problems to save his clients time and money through automation.