There's nothing wrong with your code. The problem lies in the fact that you never told Chef to install the Rubies that you defined in your role.
You have included recipe[rvm]
in the role's run_list
, which translates to recipe[rvm::default]
. Looking into the cookbook's documentation, you find that this recipe:
Installs the RVM gem and initializes Chef to use the Lightweight Resources and Providers (LWRPs). Use this recipe explicitly if you only want access to the LWRPs provided.
What you want can be best achieved by substituting recipe[rvm]
for recipe[rvm::system]
in the run_list
:
Installs the RVM codebase system-wide (that is, into /usr/local/rvm) and installs Rubies, global gems, and specific gems driven off attribute metadata. This recipe includes default and system _ install. Use this recipe by itself if you want RVM system-wide with Rubies installed, etc.