The way to add new zone/endpoint to master by api interface

I have read document " Icinga 2 API" chapter, and known can’t create runtime objects like zone/endpoint by /v1/objects/<type> api.

But after reading some times, I found Package and Stage part, can I create new new zone/endpoint runtime objects by them, and how ?

Hi,

as explained in the API docs, packages and stages are used to deploy raw configuration files. The examples in there use a host object being deployed, you can do that with any other configuration snippet as well. The Director uses the config packages to for its deployments, this is the main consumer for this API endpoint.

Cheers,
Michael

1 Like

After testing by my icinga2 cluster, it is works!

Thinks!

Another question: Is it same effect to place conf to /var/lib/icinga/api/packages/XXX/XXX/zone.d/master and /etc/icinga2/zone.d/master ?

And what is the different with /var/lib/icinga2/api/packages/_api/xxx/[ conf.d, zone.d ] ?

Hi,

_api is an internal config package and must not be modified by the user on disk. The core handles the files in there in a proper way.

You also do not place files directly to the package path on disk, but just use the REST API endpoints for that. conf.d is static configuration just for this node, zones.d needs the zone directory underneath - in the same way as you would manually put files into /etc/icinga2/zones.d.

The core uses a package path prefix on its own, this may change in the future (including migrations). So don’t write scripts which rely on /var/lib/icinga2/api/packages or something similar.

Cheers,
Michael