Remote Execution Plugin API

Is it possible to create a remote execution job_invocation using the Foreman REST API? I wasn’t able to find any relevant documentation, if so what would the JSON format look like? Thanks.

Hello,

it is possible. Best is to look at https://$yourforeman/apidoc and search for job invocations API. As long as you have REX plugin installed, you should see the description there. Also you can use hammer CLI plugin and run it with --debug to see the payloads.

Hope this helps

Yes, as Marek metniond, using hammer + apidoc is pretty neat way to figure out the right call:

hammer -d job-invocation create --job-template "my-template" \
       --inputs="my_input=my_value"\
       --search-query="host-5.foreman.test OR host-4.foreman.test" --async

Thank you for your responses they are very helpful. Using hammer simplifies my job_invocation scripting task, I can wait for it to return and parse the results. The foreman Api Rex Json structure appears to be.
{
“job_invocation” => {
“job_template_id” => 248,
“inputs” => {
“command” => “echo”
},
“ssh” => {},
“recurrence” => {},
“scheduling” => {},
“concurrency_control” => {},
“search_query” => “ip ~ 192.168.127.5”,
“targeting_type” => “static_query”
}
}