Apply where this.name does not work

I’m trying to assign a service on hosts that includes the name of the service in their vars.

service.conf -

apply Service "check_service1"{
  check_command = this.name
  assign where this.name in host.vars.service_list
}

hosts.conf -

object Host "test" {
  display_name = "Test Site"
  check_command = "dummy"
  vars.service_list = ["check_service1"]
}

after restarting i tried to execute icinga2 object list --type service but it returns nothing.

in addition, when trying assign expression like this - “check_service1” in host.vars.service_list it works but i don’t want to use it because i want it to be in a template.

thanks to anyone answering!

  • Version used icinga2 - The Icinga 2 network monitoring daemon (version: r2.13.3-1)
  • Operating System and version - ubuntu 20.04
  • Enabled features (icinga2 feature list) - checker debuglog mainlog notification
  • Icinga Web 2 version and modules (System - About) not configured
  • Config validation (icinga2 daemon -C) -
    [2022-07-14 08:25:53 +0000] information/cli: Icinga application loader (version: r2.13.3-1)
    [2022-07-14 08:25:53 +0000] information/cli: Loading configuration file(s).
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Committing config item(s).
    [2022-07-14 08:25:53 +0000] warning/ApplyRule: Apply rule ‘pd1’ (in /etc/icinga2/conf.d/pagerduty-icinga2.conf: 108:1-108:35) for type ‘Notification’ does not match anywhere!
    [2022-07-14 08:25:53 +0000] warning/ApplyRule: Apply rule ‘pagerduty-host’ (in /etc/icinga2/conf.d/pagerduty-icinga2.conf: 163:1-163:43) for type ‘Notification’ does not match anywhere!
    [2022-07-14 08:25:53 +0000] warning/ApplyRule: Apply rule ‘backup-downtime’ (in /etc/icinga2/conf.d/downtimes.conf: 5:1-5:52) for type ‘ScheduledDowntime’ does not match anywhere!
    [2022-07-14 08:25:53 +0000] warning/ApplyRule: Apply rule ‘check_passed_miner_without_actions’ (in /etc/icinga2/conf.d/services.conf: 1:0-1:49) for type ‘Service’ does not match anywhere!
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 1 IcingaApplication.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 3 HostGroups.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 1 Host.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 4 NotificationCommands.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 2 FileLoggers.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 1 CheckerComponent.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 3 Zones.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 1 Endpoint.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 247 CheckCommands.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 1 NotificationComponent.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 7 Users.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 1 UserGroup.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 3 TimePeriods.
    [2022-07-14 08:25:53 +0000] information/ConfigItem: Instantiated 4 ServiceGroups.
    [2022-07-14 08:25:53 +0000] information/ScriptGlobal: Dumping variables to file ‘/var/cache/icinga2/icinga2.vars’
    [2022-07-14 08:25:53 +0000] information/cli: Finished validating the configuration file(s).
  • If you run multiple Icinga 2 instances, the zones.conf file (or icinga2 object list --type Endpoint and icinga2 object list --type Zone) from all affected nodes - not configured

Hello @romk!

I’m sorry. I’m afraid this doesn’t exist at assign where run time.

Also a template won’t work as it’s imported even after this creation.

Best,
A/K