How can i use a puppet class name while creating a host using Foreman API
I used this curl command:
curl -k -u admin:changeme -H "Accept: version=2,application/json" -H
"Content-Type: application/json" -k -u admin:changeme -d '{ "host" : {
"name" : "test123", "hostgroup_id" : "1", "compute_resource_id" : "3",
"compute_profile_name" : "1-Small", "environment_id" : "3", "domain_id" :
"1", "mac" : "52:53:00:1e:85:93", "architecture_id" : "1",
"operatingsystem_id" : "5", "puppetclasses" : "config" } }' -X POST
"$FOREMAN_URL"
I get this following error:
{
"error": {"message":"Puppetclass(#69872206691040) expected, got
String(#69872304247800)"}
}
Am i missing something, Is there any API extension for this?
Try using "puppetclass_names" or "puppetclass_ids" (if you can look up
the IDs), and pass in an array, not a single string.
"puppetclass_ids":[1,2,3]
···
On 10/10/14 15:44, Raghava Karthik wrote:
> How can i use a puppet class name while creating a host using Foreman API
>
> _I used this curl command:_
>
>
>
> curl -k -u admin:changeme -H "Accept: version=2,application/json" -H
> "Content-Type: application/json" -k -u admin:changeme -d '{ "host" : {
> "name" : "test123", "hostgroup_id" : "1", "compute_resource_id" : "3",
> "compute_profile_name" : "1-Small", "environment_id" : "3", "domain_id"
> : "1", "mac" : "52:53:00:1e:85:93", "architecture_id" : "1",
> "operatingsystem_id" : "5", "puppetclasses" : "config" } }' -X POST
> "$FOREMAN_URL"
>
> _I get this following error:_
>
> {
> "error": {"message":"Puppetclass(#69872206691040) expected, got
> String(#69872304247800)"}
> }
>
> Am i missing something, Is there any API extension for this?
–
Dominic Cleal
Red Hat Engineering