Icinga2 backend due to re-definition of configuration by itself

I haven’t seen this issue before, and it’s pretty strange. I just updated Icinga2:

15:19UTC0 : [root@icinga /etc/icinga2/zones.d ]# yum history info 116 | grep icinga2 -B2
    Updated icinga-php-library-0.6.1-1.el7.icinga.noarch               @icinga-stable-release
    Update                     0.7.0-1.el7.icinga.noarch               @icinga-stable-release
    Updated icinga2-2.13.1-1.el7.icinga.x86_64                         @icinga-stable-release
    Update          2.13.2-1.el7.icinga.x86_64                         @icinga-stable-release
    Updated icinga2-bin-2.13.1-1.el7.icinga.x86_64                     @icinga-stable-release
    Update              2.13.2-1.el7.icinga.x86_64                     @icinga-stable-release
    Updated icinga2-common-2.13.1-1.el7.icinga.x86_64                  @icinga-stable-release
    Update                 2.13.2-1.el7.icinga.x86_64                  @icinga-stable-release
    Updated icinga2-ido-mysql-2.13.1-1.el7.icinga.x86_64               @icinga-stable-release

Now, I’m receiving the following error when trying to restart services:

[2022-02-08 15:20:17 +0000] information/cli: Icinga application loader (version: 2.13.2-1)
[2022-02-08 15:20:17 +0000] information/cli: Loading configuration file(s).
[2022-02-08 15:20:17 +0000] critical/config: Error: Object 'mail-host-notification' of type 'NotificationCommand' re-defined: in /etc/icinga2/zones.d/global-templates/commands.conf: 9:1-9:51; previous definition: in /etc/icinga2/conf.d/commands.conf: 9:1-9:51
Location: in /etc/icinga2/zones.d/global-templates/commands.conf: 9:1-9:51
/etc/icinga2/zones.d/global-templates/commands.conf(7):  */
/etc/icinga2/zones.d/global-templates/commands.conf(8):
/etc/icinga2/zones.d/global-templates/commands.conf(9): object NotificationCommand "mail-host-notification" {
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/global-templates/commands.conf(10):   command = [ ConfigDir + "/scripts/mail-host-notification.sh" ]
/etc/icinga2/zones.d/global-templates/commands.conf(11):
[2022-02-08 15:20:17 +0000] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.

I’m unsure of why this is happening, it seems to be referencing itself stating that the object has been re-defined, by itself. I’ve double checked the file (commands.conf) but there’s no other explanation.

Just figured this out literally a minute later after submitting it.

Strangely enough, the error shown in the output is what im getting at console, yet, it says it is being defined in two places, but the same place/file.

I found an identical file placed in /etc/icinga2/conf.d/, but this is not referenced in the error.

Hi & welcome to the icinga community,

The output is very clear:

[2022-02-08 15:20:17 +0000] critical/config: Error: Object 'mail-host-notification' of type 'NotificationCommand' re-defined: in /etc/icinga2/zones.d/global-templates/commands.conf: 9:1-9:51; previous definition: in /etc/icinga2/conf.d/commands.conf: 9:1-9:51
Location: in /etc/icinga2/zones.d/global-templates/commands.conf: 9:1-9:51

The object mail-host-notification is defined twice:

  1. /etc/icinga2/conf.d/commands.conf
  2. /etc/icinga2/zones.d/global-templates/commands.conf

Hence, you need to remove one of them. You could do this by disabling the inclusion of /etc/icinga2/conf.d/ which is recommended anyway.