Task templates / reuse

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.

A role seems like a very good idea.

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.