blog.kirishikistudios.com

About Me   

Just another geek

twitter.com/satully:

    Install Ruby1.9.3 with chef-solo in two ways: compiling source and using rvm

    In CentOS, default Ruby version is 1.8.7.

    I wrote a chef cookbook that lets you install version 1.9.3 via compiling source or using rvm.

    cookbook is here:

    https://github.com/chokkoyamada/chef-repo/tree/master/cookbooks/ruby/recipes

    1) From source:

    script "install_libyaml" do
      interpreter "bash"
      user "root"
      cwd "/usr/local/src/"
      code <<-EOH
      wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
      tar zxvf yaml-0.1.4.tar.gz
      cd yaml-0.1.4
      ./configure --prefix=/usr/local
      make
      make install
      EOH
    end
    
    script "install_ruby" do
      interpreter "bash"
      user "root"
      cwd "/usr/local/src/"
      code <<-EOH
      wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
      tar zxvf ruby-1.9.3-p125.tar.gz
      cd ruby-1.9.3-p125
      ./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
      make
      make install
      EOH
    end

    2) via RVM

    package "git" do
      action :install
    end
    
    script "install_rvm" do
      not_if "rubytest=`ruby -e 'puts RUBY_VERSION' | grep '1.9.3'`; echo $?"
      interpreter "bash"
      user "root"
      cwd "/usr/local/src/"
      code <<-EOH
      curl -L https://get.rvm.io | bash -s stable
      source "/usr/local/rvm/scripts/rvm"
      command rvm install 1.9.3
      rvm use 1.9.3 --default
      EOH
    end
    

    Reference:

    RVM: Ruby Version Manager - Installing RVM

    https://rvm.io/rvm/install/

    CentOSにRails 3.2.xとruby 1.9.3-p125をインストールする方法 - memo.yomukaku.net

    http://memo.yomukaku.net/entries/KzbT3fR

    — 9 months ago with 1 note
    #ruby  #rvm  #chef 
    1. chokkoyamada posted this