wrapping ansible module into another module

Hi,

There are few playbooks that I include everywhere, like this one:

`

  • include: …/…/common/tasks/checkout.yml
    vars:
    repo: ansible
    location: /opt/ansible

`

These contains just a few steps and predefined settings (like hardcoded github) that increase readability of the code. But including this playbook with relative path looks strange, so I thought about moving them to a module instead of role. Is that possible?

Thanks.

It sounds more like you should be using role dependencies rather than includes in this manner, which can be parametized with variables as well:

your_role/meta/main.yml:

dependencies:

  • { role: common, repo: ansible, location: “/opt/ansible” }

I do not believe this would be a good fit for a module, since your role is probably calling other modules itself.

Moving this task to role dependencies won't help, because I need to make
checkout only after permissions and set and dependencies are installed.

Moving this into role will require me to split these three steps into roles as
well, which is weird.

So, Ansible doesn't allow one module to call other modules, right?

You can run other modules via action plugins, but that is major overkill for this situation I think. It sounds like moving the setting of the permissions and other dependencies to the common role too, if those are in fact dependent things.

Yes. Rewriting playbooks as plugins is an overkill. I just want to
wrap a groups existing steps in more high-level step that can be
called independently from different places and that's pretty much the
maximum complexity that I want from this system.