Sha256: 0ef24b74915b682768beb9e7881794461cb239681226d619de59a899f707ab35

Contents?: true

Size: 1.88 KB

Versions: 3

Compression:

Stored size: 1.88 KB

Contents

namespace :bootstrap do
  desc "Create a standalone rbenv installation with a default ruby to use with chef-solo"
  task :rbenv do
    begin
      ruby_version
    rescue
      set :ruby_version, default_ruby_version
    end
    ruby_version.gsub!(/^ruby\-/,'')
    standup_script = <<-SH
      #!/bin/bash
      #
      # And now install rbenv
      export PATH=$HOME/bin:$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH

      HAVE_RBENV_ALREADY=`which rbenv 2>/dev/null`
      if [ $? != 0 ]; then
        echo "Install rbenv dependencies..."
        sudo yum install -y git
        echo "Building rbenv..."
        git clone git://github.com/sstephenson/rbenv.git ~/.rbenv || exit 1
        # Add rbenv to your path
        echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> .bashrc
        echo 'eval "$(rbenv init -)"' >> .bashrc
        source ~/.bash_profile
      fi;

      # Install ruby-build
      HAVE_RUBY_BUILD=`which ruby-build 2>/dev/null`
      if [ $? != 0 ]; then
        echo "Building ruby-build..."
        git clone git://github.com/sstephenson/ruby-build.git /tmp/ruby-build || exit 1
        cd /tmp/ruby-build
        PREFIX=$HOME ./install.sh
        cd $HOME
      fi;

      # Install Ruby #{ruby_version}
      HAVE_CORRECT_VERSION=`rbenv versions | grep '#{ruby_version}' | wc -l`
      if [ $HAVE_CORRECT_VERSION -eq 0 ]; then
        echo "Installing Ruby dependencies..."
        sudo yum install -y automake gcc make libtool curl zlib zlib-devel patch readline readline-devel libffi-devel openssl openssl-devel
        echo "Installing #{ruby_version}..."
        rbenv install #{ruby_version}
        rbenv global #{ruby_version}
        # Rehash!
        rbenv rehash
      fi;

      rbenv versions | grep '#{ruby_version}'
    SH
    put standup_script, "/tmp/chef-cap-#{rails_env}-rbenv-standup.sh", :mode => "0700"
    run "/tmp/chef-cap-#{rails_env}-rbenv-standup.sh"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chef_cap-0.3.20 recipes/rbenv.rb
chef_cap-0.3.19 recipes/rbenv.rb
chef_cap-0.3.18 recipes/rbenv.rb