# wrapping ansible module into another module

**URL:** <https://forum.ansible.com/t/wrapping-ansible-module-into-another-module/16826>\
**Category:** Ansible Developer\
**Created:** [November 19, 2014, 2:50pm UTC](https://forum.ansible.com/t/wrapping-ansible-module-into-another-module/16826 "2014-11-19T14:50:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anatoly\_techtonik](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anatoly\_techtonik](https://forum.ansible.com/u/anatoly_techtonik)\
**Post date:** [November 19, 2014, 2:50pm UTC](https://forum.ansible.com/t/wrapping-ansible-module-into-another-module/16826/1 "2014-11-19T14:50:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [November 20, 2014, 4:34pm UTC](https://forum.ansible.com/t/wrapping-ansible-module-into-another-module/16826/2 "2014-11-20T16:34:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anatoly\_techtonik](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anatoly\_techtonik](https://forum.ansible.com/u/anatoly_techtonik)\
**Post date:** [November 20, 2014, 4:48pm UTC](https://forum.ansible.com/t/wrapping-ansible-module-into-another-module/16826/3 "2014-11-20T16:48:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [November 20, 2014, 4:57pm UTC](https://forum.ansible.com/t/wrapping-ansible-module-into-another-module/16826/4 "2014-11-20T16:57:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anatoly\_techtonik](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anatoly\_techtonik](https://forum.ansible.com/u/anatoly_techtonik)\
**Post date:** [November 22, 2014, 11:04pm UTC](https://forum.ansible.com/t/wrapping-ansible-module-into-another-module/16826/5 "2014-11-22T23:04:15Z")

</div>

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.
