Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icinga2 REST API variable synchronization with Icinga Director. #2887

Open
haytxy opened this issue Jul 9, 2024 · 4 comments
Open

Icinga2 REST API variable synchronization with Icinga Director. #2887

haytxy opened this issue Jul 9, 2024 · 4 comments

Comments

@haytxy
Copy link

haytxy commented Jul 9, 2024

Expected Behavior

Icinga Director should be able to update a variable object if the object has a null value and the value is already provided by Icinga Director for example in Service Template or Service Set.

Current Behavior

If previously the value for the variable object was given using Icinga2 REST API and we want to overwrite this value with the help of the Icinga Director, it is impossible.

Steps to Reproduce (for bugs)

With the help of Icinga2 REST API, I passed the value "13" for the postgres_critical variable.
Which resulted in overwriting the value that I had configured in "Icinga Service Sets"

curl -k -s -S -i -u user:pass -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/objects/services/host-object!service-object -d '{ "attrs": { "vars.postgres_critical" : "13" }}'

image

I would like to reverse the process.
However, when I'm using the Icinga2 REST API to overite postgres_critical and put a null value for this variable.
curl -k -s -S -i -u user:pass -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/objects/services/host-object!service-object -d '{ "attrs": { "vars.postgres_critical" : null }}'

It doesn't change anything.
I am unable to get back the value specified in Icinga Director.
The variable postgres_critical takes the value null
Inspect >> Executed Command >> '-c' ''
and does not retrieve the value previously configured in Icinga Director.

I can only see the Icinga Director value under original_attributes.
image

How to use a value defined in Icinga Director if previously this value was put under variable by Icinga2 REST API?

Your Environment

  • Director version 1.11.0
  • Icinga Web 2: 2.12.1
  • Icinga 2 version: r2.14.0-1
  • Operating System and version: Debian Linux 11 (bullseye)
  • Webserver, PHP versions: 7.4.33
@haytxy
Copy link
Author

haytxy commented Oct 17, 2024

Hello team, is it possible to comment on this issue?

@yhabteab
Copy link
Member

yhabteab commented Oct 17, 2024

However, when I'm using the Icinga2 REST API to overite postgres_critical and put a null value for this variable.

Hi, if you want to restore the previous value of that variable you've to do it via the restore_attrs field:

curl -k -s -S -i -u user:pass -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/objects/services/host-object!service-object -d '{ "restore_attrs": [ "vars.postgres_critical" ]}'

@haytxy
Copy link
Author

haytxy commented Oct 17, 2024

@yhabteab so (1) restore_attrs using REST API (2) only after that I will be able to use Icinga Director once again?
No chance to update the variable directly from Icinga Directer if REST API was used, yes?

@yhabteab
Copy link
Member

only after that I will be able to use Icinga Director once again?

I'm not sure what you mean by that! If you create or modify something via the Icinga Director, it's basically the same as when you manually edit the *.conf files and reload the Icinga 2 service. However, you are not supposed to override values set via the REST API.

In other words, you can override values set in Icinga Director by using the Icinga 2 REST API, but not the other way around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants