Start an ansible playbook locally on the foreman server as a "schedule remote job" for each selected host with the posibility to set ansible options!

Problem:
Since it is only possible to reproduce the inventory possibilities (groups and the like) in foreman to a very limited extent (which is ok and would otherwise inflate foreman), I have the following idea:
it is possible (and works) to create dynamic inventories (and to build groups with the help of the “want_*” rules) using the foreman ansible inventory plugin. I have no idea how to call an ansible playbook locally on the foreman server (except via cmd and the -i option) so that this plugin is used (as a call option) and the variables set in foreman / visible roles are also taken into account.
In principle, it would perhaps be sufficient to have the option of specifying call parameters (such as -i) in the “run ansible playbook” function. I just don’t see this option (like as optional parameter)…

ok, the headline is a bit wrongly worded … of course every playbook is executed in the local foreman server ansible infrastructure … it’s really just about being able to pass parameters like -i to the ansible call…

I’m not sure about this. Foreman needs to pass its own inventory to ansible, not sure what would happen if you provided your one. I assume one of the inventories would just win?

in ansible it is possible to merge different inventories if you use multiple -i. Ansible merges these into one

TIL. But that would also mean you’d be able to inject hosts into the job?

in principle yes, but this is not my intention … I would actually only like to have more possibilities for classification.
Maybe I’m thinking too complicated here, but the background is that I have systems that are assigned to different groups in ansible at the same time (which is not possible with the host groups and also host_collections (at least currently (see also Host_collections and ansible variables - #20 by nofaralfasi ) cannot be used) in order to assign different values to ansible variables (and merge them). For example, if a host is in the group web server and at the same time in the group mysql, I would like to define that mysql and httpd have to be installed. Yes, I could use AWX but I want a solution that is simple without a 2nd management system.
That’s why I came up with the idea of using a dynamic inventory.

by the way: it wouldn’t really matter if the ansible inventory was extended to include more hosts, because in my opinion foreman would only be responsible for the hosts registered in foreman. hosts outside foreman would be the responsibility of the playbook creator.
Or even better / simpler idea: it should be possible to set / overwrite ansible variables per host_collection … the more i think about it: this would be really the best way with the option to select whether to merge or not (similar to the option under the ansible variables directly).