Closed sol1-matt closed 10 months ago
Same problem here: Iam trying to add Hosts from vspheredb and the sync rule wants to create a new host, even its already existing.
This Sync Rule failed when last checked at 2019-10-31 10:46:49: Exception while syncing Icinga\Module\Director\Objects\IcingaHost some_host_name: Trying to recreate icinga_host ("some_host_name")
The host exists in the director and is not coming from some local configfiles. If i click preview, i can clearly see that he want to create the host instead of ignoring/modifying it. Only one host is merged/replaced in my example, all others are created instead of modified.
Director version (System - About): 1.7.0 Icinga Web 2 version and modules (System - About): 2.7.2 Icinga 2 version (icinga2 --version): r2.11.0-1 Operating System and version: Ubuntu 16.04.6 LTS Webserver, PHP versions: Apache/2.4.41 (Ubuntu), PHP 7.3.10-1+ubuntu16.04.1+deb.sury.org+1
@sol1-matt: please append ?name=<hostname>
to your URL for now, it should then work as expected. I see that the documentation optionally suggests that skipping this should also work, so I need to figure out whether the documentation is wrong or when/how this behaviour has been changed.
@NeverUsedID: your problem is not related to this one. Please create a dedicated issue with a snaphot of a Configuration Basket containing this Import Source and Sync Rule definition.
thanks @Thomas-Gelf this works for the command line
-bash-4.2# ./icinga_director_api.sh POST director/host?name=test1 '{ "object_type": "object", "address": "123.123.123.123" }'
HTTP/1.1 200 OK
Date: Tue, 26 Nov 2019 04:02:40 GMT
Server: Apache/2.4.29 (Ubuntu)
Content-Length: 94
Content-Type: application/json
{
"address": "123.123.123.123",
"object_name": "test1",
"object_type": "object"
}
Expected Behavior
POST or PUT on and existing object will update the object as per the documentation
https://github.com/Icinga/icingaweb2-module-director/blob/master/doc/70-REST-API.md
Current Behavior
POST or PUT on and existing object give the error "trying to recreate icinga_host"
Possible Solution
Steps to Reproduce (for bugs)
setup a director user and password and configure the sample curl shell script
create a host
try and update the host (should update, it fails instead)
try and recreate the host (should create a clean host)
Your Environment
icinga2 --version
): r2.11.1-1Current workarounds
We have seens this happen in bash scripts, ansible and director automation from netbox (https://github.com/digitalocean/icingaweb2-module-netboximport). The the director automation from netbox can update host objects but other objects and templates get the same error message.
The work around for bash was to delete the object and recreate it each time. The work around for ansible has been to ignore the error and assume the object is correct. The work around for netbox automation has been to delete all objects that have already been created so they can be recreated and new ones added.