Calling an Ansible role from inside an action plugin

Hi Guys,

I want to include another playbook in my playbook.

Ansible allows to do this by using “include_role” like so:

  • include_role:
    name:
    task_from:

While this is a simple and working solution I want to offer a shorter syntax like so:

  • :

This would then internally call role:task-file, but hidden to the playbook writer, giving a cleaner syntax.

The proper way to achieve this seems to be writing an action plugin named “.py”.

This plugin then in turn calls the playbook, possibly by internally calling include_role.

My question is:

Can someone show how to call “include_role” from inside an action plugin?
I have tried but so far without success. (I was however able to call other modules)

I am using Ansible 2.0+

I think you can still include another playbook in your playbook by using ‘include’ and the name of the playbook. Would that do? It would save you having to create any custom code.

If you want you can even do a basic kind of parallel running of playbooks. See the examples here Slides 20-25 https://www.slideshare.net/bcoca/more-tips-n-tricks

Jon