# Task templates / reuse

**URL:** <https://forum.ansible.com/t/task-templates-reuse/16926>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [December 1, 2014, 4:09pm UTC](https://forum.ansible.com/t/task-templates-reuse/16926 "2014-12-01T16:09:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yvo](https://avatars.discourse-cdn.com/v4/letter/y/ea666f/32.png) [@Yvo](https://forum.ansible.com/u/Yvo)\
**Post date:** [December 1, 2014, 4:09pm UTC](https://forum.ansible.com/t/task-templates-reuse/16926/1 "2014-12-01T16:09:19Z")

</div>

In my playbook I have to do a few calls on RVM.

I do these calls with the shell action by:  
1) impersonating user x (sudo\_user)  
2) setting the shell to bash  
3) setting the working directory to y  
4) prefixing my shell command with "source {{rvm\_script\_path}} ;"

After doing 5 RVM calls this becomes a bit repetitive. For now I've put some of the arguments in a variable and use "args: {{rvm\_arg}}", but I feel there must be a better way.

Should I create a module or create a role for RVM? I'm not sure if a module would reduce much of the syntax and a role seems better suited for a sequence of tasks?

Note: I know that there is a RVM role on Ansible Galaxy, but it is focussed at installing RVM, not so much on using it.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [December 1, 2014, 9:32pm UTC](https://forum.ansible.com/t/task-templates-reuse/16926/2 "2014-12-01T21:32:19Z")

</div>

A role seems like a very good idea.

---

<div class="post-metadata">

**Author:** ![Yvo](https://avatars.discourse-cdn.com/v4/letter/y/ea666f/32.png) [@Yvo](https://forum.ansible.com/u/Yvo)\
**Post date:** [December 2, 2014, 5:06am UTC](https://forum.ansible.com/t/task-templates-reuse/16926/3 "2014-12-02T05:06:39Z")

</div>

Thanks I'll look into it.

Being a programmer I somewhat miss defining a function that you can call and reuse. But perhaps roles can offer just that.
