I have a big role i am looking to pack in a collection, and i want to create a plugin that does calls the role, instead of doing "include_role". so, i am looking for my customers to be able to put something like:
- name: call my plugin
my_plugin:
param1: "mmm"
param2: 42
and that will, internally, run some verifications, but eventually it will call on the entire role to execute (contrary to just calling a module).
all the documentation i found seem to call modules from the plugin, but nothing seems to be able to call a role (or a playbook). is there a way to achieve that?
If you really want to go this way, you can look into include_role
source code. (f.e. here https://github.com/ansible/ansible/blob/2cbfd1e350cbe1ca195d33306b5a9628667ddda8/lib/ansible/playbook/role_include.py). It doesn't look to me like a normal pugin, though.
But there is a more serious issue here: If you create something like that, it would totally obscure the role content from the user. Roles aren't 'python modules', and isolation is very weak for roles. By hiding role content (and execution) from users, you create, basically, your own version of ansible, with fresh and unknown list of bugs and quirks.
If you want to control the way code is executed, the strategy plugin may be a more reasonable place. You still allow users to see the usual execution workflow, but you'll have a great deal of control on how things are executed.
But writing strategy plugins is crazy hard. I know only one third party strategy plugin (mitogen).