Task templates / reuse

26 views
Skip to first unread message

Yvo van Beek

unread,
Dec 1, 2014, 11:09:19 AM12/1/14
to ansible...@googlegroups.com
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.

Michael DeHaan

unread,
Dec 1, 2014, 4:32:22 PM12/1/14
to ansible...@googlegroups.com
A role seems like a very good idea.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ea9353c8-5a8f-4e83-ad1b-1c4996ef60a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yvo van Beek

unread,
Dec 2, 2014, 12:06:39 AM12/2/14
to ansible...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages