-
-
Save spovich/7608665 to your computer and use it in GitHub Desktop.
add node default so it will compile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby-install | |
ruby_install_version = node["ruby_install"]["version"] | |
ruby_install_url = "https://github.com/postmodern/ruby-install/archive/v#{ruby_install_version}.tar.gz" | |
ruby_install_dir = "ruby-install-#{ruby_install_version}" | |
ruby_install_tar = "#{ruby_install_dir}.tar.gz" | |
execute "Install ruby-install" do | |
cwd "/tmp" | |
command <<-EOC | |
curl -Lo #{ruby_install_tar} #{ruby_install_url} && | |
tar -xzvf #{ruby_install_tar} && | |
cd #{ruby_install_dir} && | |
make install | |
EOC | |
creates "/usr/local/bin/ruby-install" | |
end | |
# chruby | |
chruby_version = node["chruby"]["version"] | |
chruby_url = "https://github.com/postmodern/chruby/archive/v#{chruby_version}.tar.gz" | |
chruby_dir = "chruby-#{chruby_version}" | |
chruby_tar = "#{chruby_dir}.tar.gz" | |
execute "Install chruby" do | |
cwd "/tmp" | |
command <<-EOC | |
curl -Lo #{chruby_tar} #{chruby_url} && | |
tar -xzvf #{chruby_tar} && | |
cd #{chruby_dir} && | |
make install | |
EOC | |
creates "/usr/local/bin/chruby-exec" | |
end | |
# load chruby globally and enable auto-switch | |
file "/etc/profile.d/chruby.sh" do | |
owner "root" | |
group "root" | |
mode "0755" | |
action :create_if_missing | |
content <<-EOS | |
source /usr/local/share/chruby/chruby.sh | |
source /usr/local/share/chruby/auto.sh | |
EOS | |
end | |
# where the ruby attrs look something like this (engine => array of versions) | |
# chruby: { | |
# rubies: { | |
# "ruby" => ["2.0.0-p247"] | |
# } | |
# } | |
# need to specify default node value or code below won't compile | |
node.default["chruby"]["rubies"] = {ruby: []} | |
node["chruby"]["rubies"].each do |ruby_vm, ruby_versions| | |
ruby_versions.each do |ruby_version| | |
execute "Install #{ruby_vm} #{ruby_version}" do | |
command "ruby-install #{ruby_vm} #{ruby_version}" | |
creates "/opt/rubies/#{ruby_vm}-#{ruby_version}/bin/ruby" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment