Sha256: f61a150f584b80e1a15afb0af9b4396b987018f851267d4306208c38dd409ef7

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

depend :remote, :command, "rvm"
depend :remote, :command, "chef-solo"

before "chef:setup", "rvm:bootstrap"

namespace :rvm do
  desc "Create a standalone rvm installation with a default ruby to use with chef-solo"
  task :bootstrap do
    set :rvm_ruby_version, (ChefDnaParser.parsed["environment"]["rvm_ruby_version"] rescue "ruby-1.9.3-p0" || "ruby-1.9.3-p0")
    rvm_standup_script = <<-SH
      #!/bin/bash
      #
      RVM_URL="https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer"
      export PATH=$PATH:/usr/local/rvm/bin:~/.rvm/bin
      HAVE_RVM_ALREADY=`which rvm 2>/dev/null`
      if [ $? -eq 0 ]; then
        echo "Found RVM: " `which rvm`
        echo "Looks like RVM is already on this machine. Recording to /tmp/.chef_cap_rvm_path"
        which rvm > /tmp/.chef_cap_rvm_path
        exit 0
      else
        echo "Could not find RVM, PATH IS: ${PATH}"
        echo "Going to attempt to attempt to download and install RVM from ${RVM_URL}"
      fi

      HAVE_CURL=`which curl 2>/dev/null`
      if [ $? -eq 0 ]; then
        RVM_TEMP_FILE=`mktemp /tmp/rvm_bootstrap.XXXXXX`
        curl -k $RVM_URL | sed "s/curl /curl -k /g" > $RVM_TEMP_FILE
        chmod u+rx $RVM_TEMP_FILE
        bash -s stable < $RVM_TEMP_FILE
        rm -f $RVM_TEMP_FILE
        which rvm > /tmp/.chef_cap_rvm_path
        `/tmp/.chef_cap_rvm_path` list | grep "No rvm rubies installed"
        if [ $? -eq 0 ]; then
          echo "No rvm rubies installed. Installing from capistrano setting :rvm_ruby_version #{rvm_ruby_version}"
          `cat /tmp/.chef_cap_rvm_path` install #{rvm_ruby_version}
        fi
      else
        echo "FATAL ERROR: I have no idea how to download RVM without curl!"
        exit 1
      fi
    SH
    put rvm_standup_script, "/tmp/chef-cap-#{rails_env}-rvm-standup.sh", :mode => "0700"
    sudo "/tmp/chef-cap-#{rails_env}-rvm-standup.sh"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chef_cap-0.3.7 recipes/rvm_bootstrap.rb