Transmit additional attributes when registering via Self Service API

Hello,

I am currently trying out the Director’s self service API and so far it does everything I am expecting it to do. One tiny thing I am missing in the configuration of the Self Service API is the possibility to transmit additional attributes of a host when it registers itself via the API.

The specific attribute would be the randomly generated password for the NSClient-API which I install on my icinga agents before the registration via Self Service API happens, i.e. transmitting a variable $NSPassword as host.vars.nspassword for every host registering itself.

Is this scenario doable?

Best.
Daniel

The self service api can’t change that ( REST API - Icinga Director. But you could use the default director api:

$paswd = ConvertTo-SecureString "mypass" -AsPlainText -Force
$cred = New-Object Management.Automation.PSCredential ('myuser', $paswd)
Invoke-RestMethod -Uri "https://monitoring.host.tld/director/host?name=$(Get-IcingaHostname -AutoUseFQDN $true -LowerCase $true)" -Method Post -Headers @{"Accept"="application/json"} -Credential $cred -Body (@{"vars.nspassword"="thensclientpassword"} | ConvertTo-Json)

For permissions see: Register Agent with Director Self-Service API for existing Host AND change assigned Template - Icinga Director - Icinga Community

1 Like