Modify custom variables via api and sync with director


I got a task to replace custom vars on 1500 of hosts defined in Icinga. I have done it via api like this:

curl -k -s -S -i -u automator:‘password’ -H ‘Accept: application/json’ -X POST ‘https://localhost:5665/v1/objects/hosts/hostname001’ -d ‘{ “attrs”: { “vars”: { “device_assignment” : [“ASSIGNMENTSTRING1”, “ASSIGNMENTSTRING2”] } }, “pretty”: true }’

what I have done is basically running this line for each of the hosts (shell batch file generated by a script). Commands returned HTTP 200 and I can see the variable is changed, when looking using Overview > Hosts.

but it seems not to be present when looking via Director > Hosts. Also icinga2 objects list -t Host does not show what I see via Overview > Hosts in icingaweb

what is the correct way to change such thing please? Looks like director needs to be synced with icinga2 because this change was not done using Director.

can anyone guide me please?

and two important questions at the end:

  1. are my variables set now even they are not visible in Director?
  2. can a simple future deploy in Director overwrite this change?

thanks a log

icinga 2.7.3
director 1.7.2


you’re using the icinga api and not the directors api. Look here: Rest Api - Icinga Director
If you use the icinga api, every change is temporarly in the memory until you deploy new config with the director.

1 Like