3
votes

I am try to install ruby gem using ansible. I use rvm for version management. The remote directory contain a rvmrc file to config the ruby and gemset version. However, when using ansible's command/shell module, it still uses the default ruby version, not the one instructed in rvmrc file. So my question is how can I execute command with correct ruby/gemset version?

1
Are you sure that the command is being run from the home directory where you have the rvmrc file located? It sounds like there's a chance it's not. Try invoking a command to copy rvmrc to /tmp and see if it shows up there.Bruce P
Thank you for your reply, Bruce. I have used chdir option of command module. The chdir directory contains rvmrc file. I also use bash -lc '<ruby_command>' as the command, but no luck.Harue

1 Answers

5
votes

You can invoke rvm directly like this:

/usr/local/rvm/bin/rvm all do gem install ...

where all represents all versions of ruby managed by rvm (or you can specify the version directly).