A way to apply ansible roles after registering the host

and again :wink:

I’m searching for a way to start specific (allocated via hostgroup) ansible roles for a new host direct after registering it as a part of integrating new hosts into katello (single skript solution). I can’t do that via the REST Api (at least I have not found any documentation). How else could I solve this without having to login into the katello host / into Katello?

Any idea ???

Best regards


Are these existing / already provisioned hosts which you are registering with the Katello server and you want to apply some Ansible roles during the registration process? Or you are provisioning new hosts and you want to apply some Ansible roles during/after the provisioning?

It’s worth noting that Katello is not a full replacement for Ansible Tower / AWX so if you are trying to fully automate configuration using Ansible and registering them in Katello is just 1 part of that, you may find a more complete solution going that route.

That said, anything that you can already do via the UI is also possible via the API… if it were not, then you wouldn’t be able to do it with the UI either.

Anyway, if the reason you want to avoid the UI is simply related to concerns with scale out, you could use bulk actions to select groups of hosts and apply the roles to all of them at the same time. At least this may be a good option if you will register or provision hosts in batches.

If that’s not a good option and you really need to script it per host using the API then you should look at /job_invocations to find what you need… you can always tail the logs while running it manually on the UI once, to see the exact request that is used

thanks for the advice with ‘job_invocation’ but I do not find this REST Api call in API documentation
I only find this in an older documentation from 3.18 … and this irritates me. If I can still use this, it would be fine
And yes, I want to register already existing hosts in this case … and you are right, AWX would be a nice solution, but it is not possible :frowning: I have another customer where I have done that (with callback) but this time, I need a solution with a smaler footprint and a way to do a onetime ansible run for basic config.

Best regards

Quickly skimming over apidocs.theforeman.org, it seems to show api docs for Foreman without any plugins installed. Have you tried checking the apidocs on your own instance? They should live at https://$foreman_fqdn/apidoc

Anyway, that was a detour. As long as you have the remote execution plugin available, which I assume you have, then the job invocation api is available.

thank you for the hint with https://$foreman_fqdn/apidoc !
Sometimes you don’t think about the simplest things when google is around

Best regards