What I have: Chef;
What I need: RVM installed for node[:deploy][:user][:name]. I need user-wide install, not system-wide.
What I tried latest:
script 'install_rvm' do
user = node[:deploy][:user][:name]
interpreter '/bin/bash'
code "su -l #{user} -c '\curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable'"
not_if { ::File.exists? "/home/#{user}/.rvm" }
end
When I manually run su -l <username> -c '\curl <long_url> | bash -s stable' on test server surely it works perfectly.
I expect Chef to run the same code, and in logs it seems like it does, but the next execute resource fails because in fact there is no /home/<username>/.rvm present.
Yes I know that in Chef I can specify user as user node[:deploy][:user][:name] instead of changing user with su but for some reason if I do that rvm would try to install itself in /root/.rvm (env not properly reset?).
Well, I would like to ask, why is Chef so extremely crappy even for such dead-simple tasks, but it looks like I’ve chosen the wrong place, so the question is what am I doing wrong or do I miss something obvious?
Well, at least that worked and may be useful if all better ways to do it with Chef fail for you. Here is the resource for installing ruby
And the bonus one to create
gemsetif it is not already present: