Problems using constants after upgrading from 2.13 to 2.14

Hello!
We used version 2.13.
We have several zones and each has its own constants.conf file with certain constants, for example:
We used version 2.13.
We have several zones and each has its own constants.conf file with certain constants definition, for example:
MONGO_PASS=“1111”
MYSQL_PASS=“222”
the values ​​of these constants are different for all zones.

After upgrading to version 2.14 we get the error
“Value for constant was modified. This behaviour is deprecated”

Questions:

  1. Do I understand correctly that constants need to be changed to variables? 2. What is the best way to do this? Should I put the definition of these variables in each zone’s hosts.conf? Or is there an alternative way?
    Thanks

Once defined a constant can be accessed from any file. Constants cannot be changed once they are set.
Language Reference - Icinga 2

Using hostvariables is a good approach. you can also put them into host-templates.

Do you get an error or a warning?

how to set global variables and redefine it globally for the zone, not for each host?

IMHO logically zone constants need to be migrated to the zone variables. isn’t it?

you could create multiple hosttemplates that contain the different passwords and assign the right template to the corresponding host.
the templates can inherit from a template so values can be overwritten in the child templates

so, it is not possible just to change
const NAME=VALUE to var NAME=VALUE and get everything working and full refactoring required?

hm.

This is one more point to migrate out of icinga…

IMHO global constants aren’t a good fit for configuration information that isn’t static and globally valid.

I would second the advice of @moreamazingnick and putt stuff like the mongo credentials into host vars.

This would also increase security as I expect that your current method exposes the mongo credentials on ALL hosts with an Icinga2 agent in the zone under /var/lib/icinga2/api/zones/! The same is a concern for templates!