Import Service Templates in Host Objects?

Hi all,
I have several variables for access to icingaweb and sending notifications to teams, which are no Icinga admins. To keep things simple (and because I am lazy) I created Host Templates for the several teams, e.g.

template Host "TeamA" {
  vars.icingaweb += [ "TeamA" ]
  vars.notification.mail.users += [ "TeamA" ]
}

Shall a team have access to a specific Host, I just have to type

import "TeamA"
to the specific host object.
The filter in icingaweb2 for the TeamA role is set to "_host_icingaweb=*"TeamA"*|_service_icingaweb=*"TeamA"*
So far so good. But there are also Hosts with services, where teams should not see/get notifications for all but only specific services of this host.
E.G. I have a host with several http checks where only one is important for TeamA. Given the apply rule for http

apply Service "http:" for (http => config in host.vars.http) {
import "generic-service"
check_command = "http"
vars += config
assign where host.vars.http
}

And the host object

object Host "bla" {
[...]
  vars.http["siteA"] = {
    http_vhost = "www.siteA.de"
    icingaweb += ["TeamA"]
    notification.mail.users += ["TeamA"]
  }
[....]
}

As I have both set my icingaweb2 filter to the service variable and also have notification rules for service variables, this works fine. But I want to be lazy here, too.
So I tried to create also a service template for the team and import it to the http check:

template Service "TeamA" {
  icingaweb += [ "TeamA" ]
  notification.mail.users += [ "TeamA" ]
}

object Host "bla" {
[...]
  vars.http["siteA"] = {
    http_vhost = "www.siteA.de"
    import "TeamA"
  }
}

But this does not work, I get an error, that the Template is unknown:
critical/config: Error: Import references unknown template: 'TeamA'

I could imagine, that vars += config in the service apply rule and import "TeamA" in the host object does not work together. If that’s a fact, any idea, how to solve this elegantly?

Cheers,
Marcus

You can’t import a Service template into a Host object.

All you need to do is create an identical Host template to your Service
template, and then the Host object will happily import that:

 template Host "TeamA" {
   icingaweb += [ "TeamA" ]
   notification.mail.users += [ "TeamA" ]
 }

Antony.

This would lead to an re-defined error because of two templates with the same name
Also using of another name, does not work:

template Host "TeamA" {
  vars.icingaweb += [ "TeamA" ]
  vars.notification.mail.users += [ "TeamA" ]
}
template Host "Service_TeamA" {
  icingaweb += [ "TeamA" ]
  notification.mail.users += [ "TeamA" ]
}

object Host "bla" {
[....]
  vars.http["SiteA"] = {
    http_vhost = "www.sitea.de"
    import "Service_TeamA"
  }
[....]
}

[2020-08-27 18:30:42 +0000] critical/config: Error: Import references unknown template: ‘Service_TeamA’