POST host parameter from Python (Satellite 6)


Trying to set host parameter (admittedly, this is Satellite 6.5.2…ducks), via Python, using verify=False, and I have to specify the Sat server as regular “http”.

Am providing a simple dict data structure for parameter, and passing it through json.dumps()

“parameter” : {
“name” : “puppet_role”,
“value” : “server”,

foreman production log shows:

    2019-08-16T11:49:03 [I|app|] Started POST "/api/v2/hosts/" for at 2019-08-16 11:49:03 +0200
    2019-08-16T11:49:03 [I|app|425e8cfe] Processing by Api::V2::ParametersController#create as JSON
    2019-08-16T11:49:03 [I|app|425e8cfe]   Parameters: {"parameter"=>{"name"=>"puppet_role", "value"=>"[FILTERED]"}, "apiv"=>"v2", "host_id"=>""}
    2019-08-16T11:49:03 [I|app|425e8cfe] Redirected to
    2019-08-16T11:49:03 [I|app|425e8cfe] Filter chain halted as #<Proc:0x0000000009b40100@/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/force_ssl.rb:67> rendered or redirected
    2019-08-16T11:49:03 [I|app|425e8cfe] Completed 301 Moved Permanently in 1ms (ActiveRecord: 0.0ms)

The script outputs:

POST -> POST'ing with:
{u'sort': {u'by': None, u'order': None}, u'search': None, u'results': [], u'per_page': 20, u'total': 0, u'subtotal': 0, u'page': 1}

Any advice appreciated. My feeling is, SSL problems. I have the katello-server-ca.crt and have also tried with the crt and https-version of Satellite, but things then the error slightly changes:

2019-08-16T12:01:40 [I|app|] Started POST "/api/v2/hosts/" for at 2019-08-16 12:01:40 +0200
2019-08-16T12:01:40 [I|app|fb894a18] Processing by Api::V2::ParametersController#create as JSON
2019-08-16T12:01:40 [I|app|fb894a18]   Parameters: {"parameter"=>{"name"=>"puppet_role", "value"=>"[FILTERED]"}, "apiv"=>"v2", "host_id"=>""}
2019-08-16T12:01:40 [I|app|fb894a18] Authorized user foodbenc(foodbenc)
2019-08-16T12:01:40 [I|app|fb894a18] Current user set to foodbenc (regular)
2019-08-16T12:01:40 [I|app|fb894a18]   Rendering api/v2/errors/not_found.json.rabl within api/v2/layouts/error_layout
2019-08-16T12:01:40 [I|app|fb894a18]   Rendered api/v2/errors/not_found.json.rabl within api/v2/layouts/error_layout (2.5ms)
2019-08-16T12:01:40 [I|app|fb894a18] Filter chain halted as :find_required_nested_object rendered or redirected
2019-08-16T12:01:40 [I|app|fb894a18] Completed 404 Not Found in 111ms (Views: 14.4ms | ActiveRecord: 27.4ms)

Expected outcome:

That the parameter is set.

Foreman and Proxy versions:


Foreman and Proxy plugin versions:

Other relevant data:
[e.g. logs from Foreman and/or the Proxy, modified templates, commands issued, etc]
(for logs, surround with three back-ticks to get proper formatting, e.g.)


We do have a library that wraps the API and should make integration easier. It’s using the built in API documentation to find the right URLs and does parameter verification. This is used as a basis for the foreman-ansible-modules. We’re finding various issues in the built in API documentation

Since it has built in the validation, it should make it harder to pass in incorrect data.

Thanks @ekohl - i’ll use it.

Will still like to understand what I could’ve done wrong with the vanilla method, though.

Actually having a bit of trouble understanding how to create a parameter - have dug through the source but it’s not immediately clear.

Do we use “” to set a host param? What about “api.Action()”, and “api.Param()”?

Many thanks