Adding hosts via seperate conf files

Hello everyone,

I have set up a Icinga2 installation on my system and have it running.

As a first step I wanted to add a new host but not in the conf file where the localhost was automatically configured during the setup but by creating multiple hostNUMBER.conf files.

Since I am a beginner to Icinga2 I am using a textbook as guidance and in that book it is said to create the host.conf files in “/etc/icinga2/zone.d/main/hosts” folder.
There is no mention that I have to configure the zones.conf file or anything else, just creating the host.conf and a template.conf under the “zone.d” folder.
However Icinga2 doesn’t check the configured hosts and when I run “icinga2 daemon --validate” I get the warning that the “main” folder in my “zone.d” folder couldn’t be processed (I dont have the exact message at hand right now).

Do I have to adjust the “zone.conf” file? The book is fairly new, released in 2022, so I assume it should factor in the newest features and changes.
I mighty be wrong but I read somewhere that there was an update two years ago where Icinga2 doesn’t automatically include hosts from the “zones.d” folder if not specified in the zones.conf file?

The exact message is likely to be very useful at this point.

I would personally have created the hostN.conf files under /etc/icinga2/conf.d

It’s just about the aji, though. Unless you’re planning to run multiple zones and you want to arrange your filestructure to reflect that, it seems simplest to keep them all in one place.

Things to check are the permissions on that folder that you’ve created, and on the individual files as well.

Check the icinga2.conf file to see that it’s got the include_recursive flag set correctly.

And get back with the specific error. They’re very helpful most of the time.


1 Like

Thanks for the reply @nuffi,

the warning message is

warning/config: Ignoring directory '/etc/icinga2/zones.d/main' for unknown zone 'main'.

As I was trying to find a solution I realized what the zone.d folder is intended for and since I am a beginner setting up a master with satellites is definitely not my goal right now.

I will try your solution and put my files in the /conf.d/ folder.


Edit: Your solution worked @nuffi. Thank you very much.