I was trying do install grails using gvm via ansible just like you today.
After battling for a few hours with it, I ended up stumbling upon the discussion about getting a remote user’s environment using sudo where the last comment has a solution.
So I now I rap all my shell calls in ‘bash -lc’ to get the remote user’s
environment set-uip properly. For instance :
Here’s what my task file looks like for the grails part (it also has a solution for the prompting the gvm install grails confirmation dialog – just pipe it into yes see man yes):
grails
name: check if gvm is installed
shell: test -d /usr/share/tomcat/.gvm && echo “yes” || echo “no”
register: is_gvm_installed
Thanks!!! I wish i see this earlier, i ended up solve the issue just now and then your post showed up. Seem like there are some delay for the post to show-up. Just to share my solution as well for reference.
name: gvm | Install gvm prerequisites for Grails
shell:
curl -s get.gvmtool.net | bash executable: /bin/bash
sudo: no
tags: grails
name: gvm set source | Set source for gvm
shell:
source “/home/vagrant/.gvm/bin/gvm-init.sh” && yes | gvm install grails 2.3.7 executable: /bin/bash
sudo: no
tags: grails