Critical/config: Error: Import references unknown template: 'generic-service'

Hello,

Im currently facing a issue with a new icinga Installation.
I have setup everything succesfull and im trying to monitor now some special Services for a host.
When I apply a Service to a host with arguments like

apply Service "XY" {
  import "generic-service"
}

Im getting an error, that he doesnt know the “generic-service” Template?

I have never seen this error before.

Logs dont say more Information as
critical/config: Error: Import references unknown template: 'generic-service'

In the default zones.conf File it says something to the gloabl/direcor-templates:

/*
 * Defines a global zone for distributed setups with masters,
 * satellites and clients.
 * This is required to sync configuration commands,
 * templates, apply rules, etc. to satellite and clients.
 * All nodes require the same configuration and must
 * have `accept_config` enabled in the `api` feature.
 */

object Zone "global-templates" {
  global = true
}

/*
 * Defines a global zone for the Icinga Director.
 * This is required to sync configuration commands,
 * templates, apply rules, etc. to satellite and clients.
 * All nodes require the same configuration and must
 * have `accept_config` enabled in the `api` feature.
 */

object Zone "director-global" {
  global = true
}

My icinga2-conf looks like:

/**
 * Icinga 2 configuration file
 * - this is where you define settings for the Icinga application including
 * which hosts/services to check.
 *
 * For an overview of all available configuration options please refer
 * to the documentation that is distributed as part of Icinga 2.
 */

/**
 * The constants.conf defines global constants.
 */
include "constants.conf"

/**
 * The zones.conf defines zones for a cluster setup.
 * Not required for single instance setups.
 */
include "zones.conf"

/**
 * The Icinga Template Library (ITL) provides a number of useful templates
 * and command definitions.
 * Common monitoring plugin command definitions are included separately.
 */
include <itl>
include <plugins>
include <plugins-contrib>
include <manubulon>

/**
 * This includes the Icinga 2 Windows plugins. These command definitions
 * are required on a master node when a client is used as command endpoint.
 */
include <windows-plugins>

/**
 * This includes the NSClient++ check commands. These command definitions
 * are required on a master node when a client is used as command endpoint.
 */
include <nscp>

/**
 * The features-available directory contains a number of configuration
 * files for features which can be enabled and disabled using the
 * icinga2 feature enable / icinga2 feature disable CLI commands.
 * These commands work by creating and removing symbolic links in
 * the features-enabled directory.
 */
include "features-enabled/*.conf"

/**
 * Although in theory you could define all your objects in this file
 * the preferred way is to create separate directories and files in the conf.d
 * directory. Each of these files must have the file extension ".conf".
 */
// Disabled by the node setup CLI command on 2023-09-26 11:35:39 +0000
// Disabled by the node setup CLI command on 2023-09-27 06:52:57 +0000
// include_recursive "conf.d"
// Added by the node setup CLI command on 2023-09-26 11:35:39 +0000
include "conf.d/api-users.conf"

Can anyone support on this?

During icinga2 node wizard you were asked to include conf.d or not and obviously you have chosen not (which is default and recommended). Hence, the template is not known by icinga.

Hi Roland,
thank you for your reply.
Why is it recommended?
Can I just run icinga2 node wizard now and enable including conf.d without any impact to my confs?

conf.d is only for demonstration and contain examples. They might get overwritten by a package update.

You should create your own directory structure and copy objects you want to reuse to it.

1 Like

Hi Roland,

thank you for your reply and sorry for my late answer.
I did run the icinga2 node wizard again and included conf.f
Now I set up a Teams Notification for my Hosts from icinga2-teams-notification :: Icinga Exchange
I need to create a new User like

object User "myuser1" {
  import "generic-user"
  display_name = "My User 1"
  vars.teams_webhook_url = "https://outlook.office.com/webhook/aaaaaa/IncomingWebhook/bbbbbb"
}

I obviously need to import “genric-user” but when I try to validate the config, it says again:

critical/config: Error: Import references unknown template: 'generic-user'

Can you help me with this, with instructions, what I have to do to enable all templates again?

Any Ideas on this?
@Al2Klimov or @log1c maybe?

best practice would be to disabled the inclusion of the conf.d directory (like the node wizards does by default) and then user the zones.d folder.
Inside there create folders for each zone and put the config you want to use across zones (like templates) in a folder of a global zone (e.g. global-templates)

3 Likes

Thank you @log1c
I was a bit confused but now I finally understood.
Marked as solution :slight_smile:

1 Like