Hello,
I am trying to script up adding hosts to Foreman via it's API in a Ruby
script using Rest Client with basic info only for now for ENC purposes.
However we use the Host Parameters and I cannot seem to add these. Although
there is no errors from the script, or API the host is added but no Host
Parameters ?
Basically does this:-
host_create_params = { :host =>
{
:name => "#{host}",
:environment_id => "#{env_id}"
},
:host_parameters_attributes =>
{
:name => "role",
:value => "#{role}"
},
}.to_json
begin
client["hosts"].post "#{host_create_params}", :content_type =>
'application/json'
Any ideas where I might be going wrong please ?
Thanks
Paul
Hi Paul,
Could you try again with them right after the environment (nested in the
host and not after it):
host_create_params = { :host =>
{
:name => "#{host}",
:environment_id => "#{env_id}",
:host_parameters_attributes =>
{
:name => "role",
:value => "#{role}"
}
},
}.to_json
Thanks,
Ori
···
On Thu, Apr 7, 2016 at 4:45 PM, Paul Seymour wrote:
Hello,
I am trying to script up adding hosts to Foreman via it’s API in a Ruby
script using Rest Client with basic info only for now for ENC purposes.
However we use the Host Parameters and I cannot seem to add these.
Although there is no errors from the script, or API the host is added but
no Host Parameters ?
Basically does this:-
host_create_params = { :host =>
{
:name => “#{host}”,
:environment_id => “#{env_id}”
},
:host_parameters_attributes =>
{
:name => “role”,
:value => “#{role}”
},
}.to_json
begin
client[“hosts”].post “#{host_create_params}”, :content_type =>
‘application/json’
Any ideas where I might be going wrong please ?
Thanks
Paul
–
You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.