I would like to change the host_group externally (from the client) via REST API via: curl -k -u $USERNAME:$PASSWORD -X PUT -H "Content-Type:application/json" -H "Accept:application/json" -d "{\"host\":{\"hostgroup_id\":\"4\"}}" $KATURIBASE/hosts/$HOSTNAME
Unfortunately, instead of making the change here, Foreman tries to directly create a new! host: "error": {"id":14, "errors":{"base":["Failed to create a compute ESX_Test Environment (VMware) instance sfravm-fi-test1-46: DuplicateName: The name 'sfravm-fi-test1-46' already exists. \n "]}, "full_messages":["Failed to create a compute ESX_Test Environment (VMware) instance sfravm-fi-test1-46: DuplicateName: The name 'sfravm-fi-test1-46' already exists.\n "]}
If I want to change e.g. the comment field with the above command, it works without problems.
Is this a BUG or how else can I do it via REST?
Best regards
Expected outcome:
host_group is changed Foreman and Proxy versions:
3.5.1
addition: if I try to do this via hammer, there is the same error:
hammer -u XXX -p YYY host update --name sfravm-fi-test1-46 --hostgroup-id 6
Could not update the host:
Failed to create a compute ESX_Testumgebung (VMware) instance sfravm-fi-test1-46: DuplicateName: The name 'sfravm-fi-test1-46' already exists.
or with id
hammer -u XXX -p YYY host update --id=14 --hostgroup-id 6
Could not update the host:
Failed to create a compute ESX_Testumgebung (VMware) instance sfravm-fi-test1-46: DuplicateName: The name 'sfravm-fi-test1-46' already exists.
and one more note: all hosts are created externally. Foreman / Katello should only be used as patch / basic config management (via ansible).
Via the UI it works manually but I want to do this automatically after registering a new host.
I do not know if it is of any help, I change the hostâs hostgroup via hammer like this and I think that content view and lifecycle parameters are obligatory:
Could it be that the HG youâre trying to move the host to has a compute resource assigned and Foreman (for some reason, smells like a bug to me) tries to deploy a new machine using that compute resource?
@JendaVodka
thank for your advice, but same result foreman tries to create a new host
@evgeni
yes this host group has a compute resource assigned and that could be the problem (successful test with new empty host group without any other settings). But the interesting thing is that when I do this via the UI (hosts page â select host â change group) it doesnât cause any problems.
But since all the hosts are created via foreman in the ESX environment, I canât change this (and it shouldnât be a problem).
as I said, the test with the move to a hostgroup without âdeploy onâ (i.e. without compute resource) was successful, which means that your assumption is correct.