Q:

Using ansible with rvm and rvmrc

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? 

A:

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). 