Global template problem


I’ve a problem with global template and/or my structure.

/etc/icinga2/zones.d # ll

global-templates contains my differents services, example


cat /etc/icinga2/zones.d/global-templates/packs/service1/templates.conf
template Host "service1-host" {
    // templates to use
    import "generic-host"
    // object vars

With config:

ll -d /etc/icinga2/zones.d/global-templates/packs/service1

Then I’ve added with API some hosts with this service:

cat /var/lib/icinga2/api/packages/_api/XXXXXXXXX/conf.d/hosts/host1.conf
object Host "host1" {
        import "service1-host"
        import "generic-host"
        address = "XX.XX.XX.XX"
        vars = {
        version = 1578994440.580861
        zone = "zone1"

API created this object with success.

But when i restart icinga2, on my satellite of zone1 I have:

/var/log/icinga2/icinga2.log.1:/var/lib/icinga2/api/packages/_api/XXXXXXXXXXXXXXXX/conf.d/hosts/host1.conf(2): import "service1-host"
/var/log/icinga2/icinga2.log.1:[2020-01-13 13:18:10 +0100] critical/ApiListener: Error: Import references unknown template: 'service1-host’

If I look on


My service service1-host is present

I’ve activated global-templates in my config in /etc/icinga2/zones.conf

/* global templates for top down sync config */
object Zone "global-templates" {
  global = true

Then I can precise that icinga2 daemon --validate reports no error for this service1-host

Is there anything I miss?
Thanks for help


I’m confused.

Does you satellite in zone1 have the global-templates zone in their zones.conf file?

Side note: You don’t need to import the generic-host template to the host1 host, because it is already imported by the service1-host template

1 Like

Thanks for answer

/etc/icinga2/zones.conf on satellite
contains all the config (master, satellite, …) and:

/* global templates for top down sync config */
object Zone "global-templates" {
  global = true

Thanks for note

What does the API say when you query it for the template?

On my master:

curl -k -s -u “admin:${PASSWORD_API_ADMIN}” ‘https://localhost:5665/v1/templates/hosts

I can retrieve my template here: (and others)

        "location": {
            "first_column": 0.0,
            "first_line": 1.0,
            "last_column": 23.0,
            "last_line": 1.0,
            "path": "/etc/icinga2/zones.d/global-templates/packs/service1/templates.conf"
        "name": "service1-host",
        "type": "Host"

I thought the problem.

In fact on my satellites I had some config on


But this config was duplicated by new conf I have added on:


(on master)

In fact icinga2 restarted with success on master and satellite but I thought errors on:


Now my template service1 and others are working.

Thanks for help!

1 Like