├── recipes ├── .gitkeep ├── vagrant.rb ├── gem_package.rb ├── default.rb ├── system.rb ├── user.rb ├── system_install.rb └── user_install.rb ├── attributes ├── .gitkeep ├── gem_package.rb ├── vagrant.rb └── default.rb ├── test ├── integration │ ├── data_bags │ │ └── users │ │ │ ├── virgil1.json │ │ │ ├── virgil2.json │ │ │ └── wigglebottom.json │ ├── rubies │ │ └── bats │ │ │ ├── verify_1.9.3.bats │ │ │ ├── verify_ree.bats │ │ │ ├── verify_jruby.bats │ │ │ ├── verify_rubygems_version_support.bats │ │ │ ├── _common.bash │ │ │ └── verify_patch_support.bats │ ├── rvm_versions │ │ └── bats │ │ │ └── version_pinning.bats │ └── stock_system_and_user │ │ └── bats │ │ └── system.bats └── unit │ └── chef │ └── rvm │ └── recipe_helpers_spec.rb ├── .travis.yml ├── .gitignore ├── Berksfile ├── Gemfile ├── templates └── default │ ├── rvmrc.erb │ ├── vagrant-chef-solo-wrapper.erb │ └── vagrant-chef-client-wrapper.erb ├── libraries ├── chef_rvm_set_helpers.rb ├── gem_package_monkeypatch.rb ├── chef_rvm_version_helpers.rb ├── chef_rvm_environment_helpers.rb ├── rvm_chef_user_environment.rb ├── chef_rvm_shell_helpers.rb ├── chef_rvm_string_helpers.rb ├── chef_rvm_gemset_helpers.rb ├── chef_rvm_ruby_helpers.rb ├── rvm_shell_chef_wrapper.rb ├── chef_rvm_string_cache.rb ├── rvm_rubygems_package.rb └── chef_rvm_recipe_helpers.rb ├── Rakefile ├── resources ├── default_ruby.rb ├── environment.rb ├── ruby.rb ├── gemset.rb ├── wrapper.rb ├── global_gem.rb ├── gem.rb └── shell.rb ├── .kitchen.yml ├── providers ├── default_ruby.rb ├── environment.rb ├── wrapper.rb ├── global_gem.rb ├── shell.rb ├── gemset.rb └── ruby.rb ├── metadata.rb ├── CHANGELOG.md └── README.md /recipes/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /attributes/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/data_bags/users/virgil1.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "virgil1" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /test/integration/data_bags/users/virgil2.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "virgil2" 3 | } 4 | 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 1.9.3 4 | bundler_args: --without integration 5 | -------------------------------------------------------------------------------- /test/integration/data_bags/users/wigglebottom.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "wigglebottom" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | Berksfile.lock 3 | .vagrant 4 | .kitchen/ 5 | .kitchen.local.yml 6 | .bundle/ 7 | tmp/ 8 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | site :opscode 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'apt' 7 | cookbook 'yum' 8 | cookbook 'java' 9 | cookbook 'user' 10 | end 11 | -------------------------------------------------------------------------------- /test/integration/rubies/bats/verify_1.9.3.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | rubie="1.9.3" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run_nokogiri_openssl_test $rubie 9 | } 10 | -------------------------------------------------------------------------------- /test/integration/rubies/bats/verify_ree.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | export rubie="ree" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run_nokogiri_openssl_test $rubie 9 | } 10 | -------------------------------------------------------------------------------- /test/integration/rubies/bats/verify_jruby.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | rubie="jruby" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run rvm $rubie do gem install jruby-openssl --no-ri --no-rdoc 9 | [ $status -eq 0 ] 10 | 11 | run_nokogiri_openssl_test $rubie 12 | } 13 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rake' 4 | gem 'foodcritic' 5 | gem 'minitest' 6 | 7 | # allow CI to override the version of Chef for matrix testing 8 | gem 'chef', (ENV['CHEF_VERSION'] || '>= 0.10.10') 9 | 10 | group :integration do 11 | gem 'berkshelf', '~> 1.3.1' 12 | gem 'test-kitchen', '~> 1.0.0.alpha.3' 13 | gem 'kitchen-vagrant', '~> 0.7.4' 14 | end 15 | -------------------------------------------------------------------------------- /test/integration/rubies/bats/verify_rubygems_version_support.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | rubie="1.8.7" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run_nokogiri_openssl_test $rubie 9 | } 10 | 11 | @test "Installs RubyGems 1.6.0 in RVM $rubie" { 12 | run rvm 1.8.7 do gem --version 13 | [ "$status" -eq 0 ] 14 | [ "$output" = "1.6.0" ] 15 | } 16 | -------------------------------------------------------------------------------- /test/integration/rvm_versions/bats/version_pinning.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | @test "virgil1 user has rvm-1.17.10" { 4 | run sudo -u virgil1 -i rvm version 5 | [ $status -eq 0 ] 6 | [ "$(echo $output | awk '{print $2}')" = "1.17.10" ] 7 | } 8 | 9 | @test "virgil2 user has rvm-1.16.20" { 10 | run sudo -u virgil2 -i rvm version 11 | [ $status -eq 0 ] 12 | [ "$(echo $output | awk '{print $2}')" = "1.16.20" ] 13 | } 14 | -------------------------------------------------------------------------------- /templates/default/rvmrc.erb: -------------------------------------------------------------------------------- 1 | # rvm configuration 2 | # 3 | # Generated by Chef for <%= node['fqdn'] %> 4 | # Local modifications will be overwritten. 5 | # 6 | <% if @root_install -%> 7 | umask g+w 8 | <% end -%> 9 | export rvm_path="<%= @rvm_path %>" 10 | 11 | <% unless @rvm_gem_options.empty? -%> 12 | export rvm_gem_options="<%= @rvm_gem_options %>" 13 | <% end -%> 14 | <% @rvmrc.each_pair do |k,v| -%> 15 | export <%= k %>=<%= v %> 16 | <% end -%> 17 | -------------------------------------------------------------------------------- /libraries/chef_rvm_set_helpers.rb: -------------------------------------------------------------------------------- 1 | class Chef 2 | module RVM 3 | module SetHelpers 4 | def rvm_do(user = nil) 5 | # Use Gem's version comparing code to compare the two strings 6 | rvm_version = VersionCache.fetch_version(user).gsub(/(-|_|#)/, '.') 7 | if Gem::Version.new(rvm_version) < Gem::Version.new("1.8.6") 8 | "exec" 9 | else 10 | "do" 11 | end 12 | end 13 | 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /test/integration/rubies/bats/_common.bash: -------------------------------------------------------------------------------- 1 | setup() { 2 | source /etc/profile.d/rvm.sh 3 | } 4 | 5 | run_nokogiri_openssl_test() { 6 | local rubie="$1" 7 | local https_url="https://google.com" 8 | local requires="require 'nokogiri';" 9 | local script="$requires puts Nokogiri::HTML(open('$https_url')).css('input')" 10 | 11 | run rvm $rubie do gem install nokogiri --no-ri --no-rdoc 12 | [ "$status" -eq 0 ] 13 | 14 | run rvm $rubie do ruby -rrubygems -ropen-uri -e "$script" 15 | [ "$status" -eq 0 ] 16 | } 17 | -------------------------------------------------------------------------------- /test/integration/rubies/bats/verify_patch_support.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | rubie="1.9.3-p327-railsexpress" 4 | 5 | load _common 6 | 7 | @test "RVM $rubie can use nokogiri with openssl" { 8 | run_nokogiri_openssl_test $rubie 9 | } 10 | 11 | # For more details, please see: 12 | # https://github.com/fnichol/chef-rvm/pull/137#issuecomment-12258247 13 | @test "RVM $rubie can use patched functionality" { 14 | script="puts Thread.current.thread_variable_set :foo, 'bar'" 15 | 16 | run rvm $rubie do ruby -e "$script" 17 | [ "$status" -eq 0 ] 18 | [ "$output" = "bar" ] 19 | } 20 | -------------------------------------------------------------------------------- /templates/default/vagrant-chef-solo-wrapper.erb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # RVM-aware chef-solo wrapper 4 | # 5 | # Generated by Chef for <%= node['fqdn'] %> 6 | # Local modifications will be overridden 7 | 8 | if [[ -d "<%= node['rvm']['root_path'] %>" ]] ; then 9 | export PATH="/bin:<%= node['rvm']['root_path'] %>:$PATH" 10 | rvm_path='<%= node['rvm']['root_path'] %>' 11 | export rvm_path 12 | unset RUBY_VERSION 13 | unset GEM_HOME 14 | unset GEM_PATH 15 | unset MY_RUBY_HOME 16 | unset IRBRC 17 | rvm_ruby_string='system' 18 | export rvm_ruby_string 19 | unset rvm_gemset_name 20 | unset MAGLEV_HOME 21 | fi 22 | 23 | exec <%= node['rvm']['vagrant']['system_chef_solo'] %> "$@" 24 | -------------------------------------------------------------------------------- /templates/default/vagrant-chef-client-wrapper.erb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # RVM-aware chef-client wrapper 4 | # 5 | # Generated by Chef for <%= node['fqdn'] %> 6 | # Local modifications will be overridden 7 | 8 | if [[ -d "<%= node['rvm']['root_path'] %>" ]] ; then 9 | export PATH="/bin:<%= node['rvm']['root_path'] %>:$PATH" 10 | rvm_path='<%= node['rvm']['root_path'] %>' 11 | export rvm_path 12 | unset RUBY_VERSION 13 | unset GEM_HOME 14 | unset GEM_PATH 15 | unset MY_RUBY_HOME 16 | unset IRBRC 17 | rvm_ruby_string='system' 18 | export rvm_ruby_string 19 | unset rvm_gemset_name 20 | unset MAGLEV_HOME 21 | fi 22 | 23 | exec <%= node['rvm']['vagrant']['system_chef_client'] %> "$@" 24 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | 3 | require 'foodcritic' 4 | require 'rake/testtask' 5 | 6 | # FC041 is excluded because we want to preserve the official RVM installation 7 | # process as much as possible, i.e. using curl to download the installer. 8 | FoodCritic::Rake::LintTask.new do |t| 9 | t.options = { :fail_tags => ['any'], :tags => ['~FC041'] } 10 | end 11 | 12 | Rake::TestTask.new do |t| 13 | t.name = "unit" 14 | t.test_files = FileList['test/unit/**/*_spec.rb'] 15 | t.verbose = true 16 | end 17 | 18 | begin 19 | require 'kitchen/rake_tasks' 20 | Kitchen::RakeTasks.new 21 | rescue LoadError 22 | puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI'] 23 | end 24 | 25 | task :default => [:foodcritic, :unit] 26 | -------------------------------------------------------------------------------- /attributes/gem_package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Attributes:: gem_package 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2010, 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | # rvm ruby that will be used for gem_package resources 23 | default['rvm']['gem_package']['rvm_string'] = node['rvm']['default_ruby'] 24 | -------------------------------------------------------------------------------- /attributes/vagrant.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Attributes:: vagrant 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2010, 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | default['rvm']['vagrant']['system_chef_client'] = "/opt/vagrant_ruby/bin/chef-client" 23 | default['rvm']['vagrant']['system_chef_solo'] = "/opt/vagrant_ruby/bin/chef-solo" 24 | -------------------------------------------------------------------------------- /resources/default_ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: default_ruby 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :create 23 | 24 | attribute :ruby_string, :kind_of => String, :name_attribute => true 25 | attribute :user, :kind_of => String 26 | attribute :patch, :kind_of => String 27 | 28 | def initialize(*args) 29 | super 30 | @action = :create 31 | end 32 | -------------------------------------------------------------------------------- /resources/environment.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: environment 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :create 23 | 24 | attribute :ruby_string, :kind_of => String, :name_attribute => true 25 | attribute :user, :kind_of => String 26 | attribute :patch, :kind_of => String 27 | 28 | def initialize(*args) 29 | super 30 | @action = :create 31 | end 32 | -------------------------------------------------------------------------------- /resources/ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: ruby 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :install, :uninstall, :remove 23 | 24 | attribute :ruby_string, :kind_of => String, :name_attribute => true 25 | attribute :user, :kind_of => String 26 | attribute :patch, :kind_of => String 27 | attribute :rubygems_version, :kind_of => String 28 | 29 | def initialize(*args) 30 | super 31 | @action = :install 32 | end 33 | -------------------------------------------------------------------------------- /resources/gemset.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: gemset 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :create, :delete, :empty, :update 23 | 24 | attribute :gemset, :kind_of => String, :name_attribute => true 25 | attribute :ruby_string, :kind_of => String, :regex => /^[^@]+$/ 26 | attribute :user, :kind_of => String 27 | attribute :patch, :kind_of => String 28 | 29 | def initialize(*args) 30 | super 31 | @action = :create 32 | end 33 | -------------------------------------------------------------------------------- /recipes/vagrant.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: vagrant 4 | # 5 | # Copyright 2011, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | template "/usr/local/bin/chef-client" do 21 | source "vagrant-chef-client-wrapper.erb" 22 | owner "root" 23 | group "root" 24 | mode "0755" 25 | end 26 | 27 | template "/usr/local/bin/chef-solo" do 28 | source "vagrant-chef-solo-wrapper.erb" 29 | owner "root" 30 | group "root" 31 | mode "0755" 32 | end 33 | 34 | group "rvm" do 35 | members ["vagrant"] 36 | append true 37 | end 38 | -------------------------------------------------------------------------------- /resources/wrapper.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: wrapper 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :create 23 | 24 | attribute :prefix, :kind_of => String, :name_attribute => true 25 | attribute :ruby_string, :kind_of => String 26 | attribute :binary, :kind_of => String 27 | attribute :binaries, :kind_of => Array 28 | attribute :user, :kind_of => String 29 | attribute :patch, :kind_of => String 30 | 31 | def initialize(*args) 32 | super 33 | @action = :create 34 | end 35 | -------------------------------------------------------------------------------- /recipes/gem_package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: gem_package 4 | # 5 | # Copyright 2011, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | node_val = node['rvm']['gem_package']['rvm_string'] 21 | case node_val 22 | when String 23 | rvm_descriptor = node_val + " RVM Ruby" 24 | when Array 25 | last = node_val.pop 26 | rvm_descriptor = [ node_val.join(', '), last ].join(' & ') + " RVM Rubies" 27 | end 28 | 29 | patch_gem_package 30 | 31 | ::Chef::Log.info "gem_package resource has been patched to use provider " << 32 | "Chef::Provider::Package::RVMRubygems and will install gems to " << 33 | "the #{rvm_descriptor}." 34 | -------------------------------------------------------------------------------- /resources/global_gem.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: global_gem 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :install, :upgrade, :remove, :purge 23 | 24 | attribute :package_name, :kind_of => String, :name_attribute => true 25 | attribute :version, :kind_of => String 26 | attribute :source, :kind_of => String 27 | attribute :options, :kind_of => Hash 28 | attribute :gem_binary, :kind_of => String 29 | attribute :user, :kind_of => String 30 | 31 | def initialize(*args) 32 | super 33 | @action = :install 34 | end 35 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: default 4 | # 5 | # Copyright 2010, 2011, Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # install rvm api gem during chef compile phase 21 | chef_gem 'rvm' do 22 | action :install 23 | version '>= 1.11.3.6' 24 | end 25 | require 'rvm' 26 | 27 | create_rvm_shell_chef_wrapper 28 | create_rvm_chef_user_environment 29 | 30 | class Chef::Resource 31 | # mix in #rvm_cmd_wrap helper into resources 32 | include Chef::RVM::ShellHelpers 33 | end 34 | 35 | class Chef::Recipe 36 | # mix in recipe helpers 37 | include Chef::RVM::ShellHelpers 38 | include Chef::RVM::RecipeHelpers 39 | include Chef::RVM::StringHelpers 40 | end 41 | -------------------------------------------------------------------------------- /test/integration/stock_system_and_user/bats/system.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | default_ruby="ruby-1.9.3-p194" 4 | https_url="https://google.com" 5 | 6 | setup() { 7 | source /etc/profile.d/rvm.sh 8 | } 9 | 10 | @test "creates RVM directory" { 11 | [ -d "/usr/local/rvm" ] 12 | } 13 | 14 | @test "sources into environment" { 15 | [ "$(type rvm | head -1)" = "rvm is a function" ] 16 | } 17 | 18 | @test "installs $default_ruby" { 19 | run rvm list strings 20 | [ $status -eq 0 ] 21 | [ $output = "$default_ruby" ] 22 | } 23 | 24 | @test "sets $default_ruby as the default" { 25 | run rvm list default string 26 | [ $status -eq 0 ] 27 | [ ${lines[0]} = "$default_ruby" ] 28 | } 29 | 30 | @test "default Ruby can use openssl from stdlib" { 31 | expr="puts OpenSSL::PKey::RSA.new(32).to_pem" 32 | run rvm $default_ruby do ruby -ropenssl -e "$expr" 33 | [ $status -eq 0 ] 34 | } 35 | 36 | @test "default Ruby can install nokogiri gem" { 37 | run rvm $default_ruby do gem install nokogiri --no-ri --no-rdoc 38 | [ $status -eq 0 ] 39 | } 40 | 41 | @test "default Ruby can use nokogiri with openssl" { 42 | expr="puts Nokogiri::HTML(open('$https_url')).css('input')" 43 | run rvm $default_ruby do ruby -ropen-uri -rnokogiri -e "$expr" 44 | [ $status -eq 0 ] 45 | } 46 | -------------------------------------------------------------------------------- /libraries/gem_package_monkeypatch.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library: gem_package resource monkey patch 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | ## 23 | # Patch Chef::Resource::GemPackage resource to use the RVMRubygems provider. 24 | # This has potentially dangerous side effects and should be considered 25 | # experimental. You have been warned. 26 | def patch_gem_package 27 | ::Chef::Resource::GemPackage.class_eval do 28 | def initialize(name, run_context=nil) 29 | super 30 | @resource_name = :gem_package 31 | @provider = Chef::Provider::Package::RVMRubygems 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /libraries/chef_rvm_version_helpers.rb: -------------------------------------------------------------------------------- 1 | class Chef 2 | module RVM 3 | module ShellHelpers 4 | # stub to satisfy VersionCache (library load order not guarenteed) 5 | end 6 | 7 | module VersionHelpers 8 | def rvm_version(user = nil) 9 | VersionCache.fetch_version(user) 10 | end 11 | end 12 | 13 | class VersionCache 14 | class << self 15 | include Chef::Mixin::ShellOut 16 | include Chef::RVM::ShellHelpers 17 | end 18 | 19 | def self.fetch_version(user = nil) 20 | @@versions ||= Hash.new 21 | rvm_install = user || "system" 22 | @@versions[rvm_install] ||= rvm_version(user) 23 | end 24 | 25 | def self.rvm_version(user = nil) 26 | cmd = "rvm version | cut -d ' ' -f 2" 27 | 28 | if user 29 | user_dir = Etc.getpwnam(user).dir 30 | environment = { 'USER' => user, 'HOME' => user_dir } 31 | else 32 | user_dir = nil 33 | environment = nil 34 | end 35 | 36 | version = shell_out!( 37 | rvm_wrap_cmd(cmd, user_dir), :env => environment).stdout.strip 38 | 39 | Chef::Log.debug "RVM version = #{version} (#{user || 'system'})" 40 | 41 | version 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /recipes/system.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: system 4 | # 5 | # Copyright 2010, 2011 Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe "rvm::system_install" 21 | 22 | perform_install_rubies = node['rvm']['install_rubies'] == true || 23 | node['rvm']['install_rubies'] == "true" 24 | 25 | if perform_install_rubies 26 | install_rubies :rubies => node['rvm']['rubies'], 27 | :default_ruby => node['rvm']['default_ruby'], 28 | :global_gems => node['rvm']['global_gems'], 29 | :gems => node['rvm']['gems'] 30 | end 31 | 32 | # add users to rvm group 33 | group 'rvm' do 34 | members node['rvm']['group_users'] 35 | 36 | only_if { node['rvm']['group_users'].any? } 37 | end 38 | -------------------------------------------------------------------------------- /resources/gem.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: gem 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :install, :upgrade, :remove, :purge 23 | 24 | attribute :package_name, :kind_of => String, :name_attribute => true 25 | attribute :version, :kind_of => String 26 | attribute :ruby_string, :kind_of => String, :default => "default" 27 | attribute :response_file, :kind_of => String 28 | attribute :source, :kind_of => String 29 | attribute :options, :kind_of => Hash 30 | attribute :gem_binary, :kind_of => String 31 | attribute :user, :kind_of => String 32 | 33 | def initialize(*args) 34 | super 35 | @action = :install 36 | @provider = Chef::Provider::Package::RVMRubygems 37 | end 38 | -------------------------------------------------------------------------------- /resources/shell.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Resource:: shell 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | actions :run 23 | 24 | attribute :name, :kind_of => String, :name_attribute => true 25 | attribute :ruby_string, :kind_of => String, :default => "default" 26 | attribute :code, :kind_of => String 27 | attribute :creates, :kind_of => String 28 | attribute :cwd, :kind_of => String 29 | attribute :environment, :kind_of => Hash 30 | attribute :group, :kind_of => String 31 | attribute :path, :kind_of => Array 32 | attribute :returns, :kind_of => Array, :default => [ 0 ] 33 | attribute :timeout, :kind_of => Integer 34 | attribute :user, :kind_of => String 35 | attribute :umask, :kind_of => String 36 | attribute :patch, :kind_of => String 37 | 38 | def initialize(*args) 39 | super 40 | @action = :run 41 | end 42 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver_plugin: vagrant 3 | 4 | platforms: 5 | - name: ubuntu-12.04 6 | driver_config: 7 | box: opscode-ubuntu-12.04 8 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-ubuntu-12.04.box 9 | run_list: 10 | - recipe[apt] 11 | - name: ubuntu-10.04 12 | driver_config: 13 | box: opscode-ubuntu-10.04 14 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-ubuntu-10.04.box 15 | run_list: 16 | - recipe[apt] 17 | - name: centos-6.3 18 | driver_config: 19 | box: opscode-centos-6.3 20 | box_url: https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-centos-6.3.box 21 | run_list: 22 | - recipe[yum::epel] 23 | 24 | suites: 25 | - name: stock_system_and_user 26 | run_list: 27 | - recipe[user::data_bag] 28 | - recipe[rvm::system] 29 | - recipe[rvm::user] 30 | attributes: 31 | users: 32 | - wigglebottom 33 | rvm: 34 | user_installs: 35 | - user: wigglebottom 36 | default_ruby: 1.8.7 37 | - name: rubies 38 | run_list: 39 | - recipe[java] 40 | - recipe[rvm::system] 41 | attributes: 42 | rvm: 43 | default_ruby: system 44 | rubies: 45 | - 1.9.3 46 | - version: 1.9.3-p327 47 | patch: railsexpress 48 | - version: 1.8.7 49 | rubygems_version: 1.6.0 50 | - jruby 51 | - ree 52 | - name: rbx 53 | run_list: 54 | - recipe[rvm::system] 55 | attributes: 56 | rvm: 57 | default_ruby: rbx 58 | - name: rvm_versions 59 | run_list: 60 | - recipe[user::data_bag] 61 | - recipe[rvm::user_install] 62 | attributes: 63 | users: 64 | - virgil1 65 | - virgil2 66 | rvm: 67 | user_installs: 68 | - user: virgil1 69 | version: 1.17.10 70 | - user: virgil2 71 | version: 1.16.20 72 | -------------------------------------------------------------------------------- /libraries/chef_rvm_environment_helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: Chef::RVM::EnvironmentHelpers 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | class Chef 23 | module RVM 24 | module RubyHelpers 25 | # stub to satisfy EnvironmentHelpers (library load order not guarenteed) 26 | end 27 | 28 | module GemsetHelpers 29 | # stub to satisfy EnvironmentHelpers (library load order not guarenteed) 30 | end 31 | 32 | module EnvironmentHelpers 33 | include RubyHelpers 34 | include GemsetHelpers 35 | 36 | ## 37 | # Determines whether or not and ruby/gemset environment exists 38 | # 39 | # @param [String, #to_s] the fully qualified RVM ruby string 40 | # @return [Boolean] does this environment exist? 41 | def env_exists?(ruby_string) 42 | return true if system_ruby?(ruby_string) 43 | 44 | rubie = select_ruby(ruby_string) 45 | gemset = select_gemset(ruby_string) 46 | 47 | if gemset 48 | gemset_exists?(:ruby => rubie, :gemset => gemset) 49 | else 50 | ruby_installed?(rubie) 51 | end 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /recipes/user.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: user 4 | # 5 | # Copyright 2011 Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'rvm::user_install' 21 | 22 | Array(node['rvm']['user_installs']).each do |rvm_user| 23 | perform_install_rubies = rvm_user['install_rubies'] == true || 24 | rvm_user['install_rubies'] == "true" || 25 | node['rvm']['user_install_rubies'] == true || 26 | node['rvm']['user_install_rubies'] == "true" 27 | rubies = rvm_user['rubies'] || 28 | node['rvm']['user_rubies'] 29 | default_ruby = rvm_user['default_ruby'] || 30 | node['rvm']['user_default_ruby'] 31 | global_gems = rvm_user['global_gems'] || 32 | node['rvm']['user_global_gems'] 33 | gems = rvm_user['gems'] || 34 | node['rvm']['user_gems'] 35 | 36 | if perform_install_rubies 37 | install_rubies :rubies => rubies, 38 | :default_ruby => default_ruby, 39 | :global_gems => global_gems, 40 | :gems => gems, 41 | :user => rvm_user['user'] 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /libraries/rvm_chef_user_environment.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: RVM::ChefUserEnvironment 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | def create_rvm_chef_user_environment 23 | klass = Class.new(::RVM::Environment) do 24 | attr_reader :user, :source_environment 25 | 26 | def initialize(user = nil, environment_name = "default", options = {}) 27 | @source_environment = options.delete(:source_environment) 28 | @source_environment = true if @source_environment.nil? 29 | @user = user 30 | # explicitly set rvm_path if user is set 31 | if @user.nil? 32 | config['rvm_path'] = @@root_rvm_path 33 | else 34 | config['rvm_path'] = File.join(Etc.getpwnam(@user).dir, '.rvm') 35 | end 36 | 37 | merge_config! options 38 | @environment_name = environment_name 39 | @shell_wrapper = ::RVM::Shell::ChefWrapper.new(@user) 40 | @shell_wrapper.setup do |s| 41 | if source_environment 42 | source_rvm_environment 43 | use_rvm_environment 44 | end 45 | end 46 | end 47 | 48 | def self.root_rvm_path=(path) 49 | @@root_rvm_path = path 50 | end 51 | end 52 | ::RVM.const_set('ChefUserEnvironment', klass) 53 | 54 | ::RVM::ChefUserEnvironment.root_rvm_path = node['rvm']['root_path'] 55 | end 56 | -------------------------------------------------------------------------------- /recipes/system_install.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: system_install 4 | # 5 | # Copyright 2010, 2011 Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'rvm' 21 | 22 | script_flags = build_script_flags(node['rvm']['branch'], node['rvm']['version']) 23 | upgrade_strategy = build_upgrade_strategy(node['rvm']['upgrade']) 24 | installer_url = node['rvm']['installer_url'] 25 | rvm_prefix = ::File.dirname(node['rvm']['root_path']) 26 | rvm_gem_options = node['rvm']['rvm_gem_options'] 27 | rvmrc = node['rvm']['rvmrc'] 28 | 29 | install_pkg_prereqs 30 | 31 | # Build the rvm group ahead of time, if it is set. This allows avoiding 32 | # collision with later processes which may set a guid explicitly 33 | if node['rvm']['group_id'] != 'default' 34 | g = group 'rvm' do 35 | group_name 'rvm' 36 | gid node['rvm']['group_id'] 37 | action :nothing 38 | end 39 | g.run_action(:create) 40 | end 41 | 42 | rvmrc_template :rvm_prefix => rvm_prefix, 43 | :rvm_gem_options => rvm_gem_options, 44 | :rvmrc => rvmrc, 45 | :rvmrc_file => "/etc/rvmrc" 46 | 47 | install_rvm :rvm_prefix => rvm_prefix, 48 | :installer_url => installer_url, 49 | :script_flags => script_flags 50 | 51 | upgrade_rvm :rvm_prefix => rvm_prefix, 52 | :upgrade_strategy => upgrade_strategy 53 | -------------------------------------------------------------------------------- /recipes/user_install.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Recipe:: user_install 4 | # 5 | # Copyright 2011 Fletcher Nichol 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | include_recipe 'rvm' 21 | 22 | install_pkg_prereqs 23 | 24 | Array(node['rvm']['user_installs']).each do |rvm_user| 25 | version = rvm_user['version'] || node['rvm']['version'] 26 | branch = rvm_user['branch'] || node['rvm']['branch'] 27 | 28 | script_flags = build_script_flags(branch, version) 29 | upgrade_strategy = build_upgrade_strategy(rvm_user['upgrade']) 30 | installer_url = rvm_user['installer_url'] || node['rvm']['installer_url'] 31 | rvm_prefix = rvm_user['home'] || 32 | "#{node['rvm']['user_home_root']}/#{rvm_user['user']}" 33 | rvm_gem_options = rvm_user['rvm_gem_options'] || node['rvm']['rvm_gem_options'] 34 | rvmrc = rvm_user['rvmrc'] || node['rvm']['rvmrc'] 35 | 36 | rvmrc_template :rvm_prefix => rvm_prefix, 37 | :rvm_gem_options => rvm_gem_options, 38 | :rvmrc => rvmrc, 39 | :user => rvm_user['user'] 40 | 41 | install_rvm :rvm_prefix => rvm_prefix, 42 | :installer_url => installer_url, 43 | :script_flags => script_flags, 44 | :user => rvm_user['user'] 45 | 46 | upgrade_rvm :rvm_prefix => rvm_prefix, 47 | :upgrade_strategy => upgrade_strategy, 48 | :user => rvm_user['user'] 49 | end 50 | -------------------------------------------------------------------------------- /libraries/chef_rvm_shell_helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: Chef::RVM::ShellHelpers 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | class Chef 23 | module RVM 24 | module ShellHelpers 25 | ## 26 | # Finds the correct shell profile to source to init an RVM-aware 27 | # shell environment 28 | # 29 | # @param [String] a user's home directory path if this is for a user or 30 | # nil if it is in a system context 31 | # @return [String] full path the shell profile 32 | def find_profile_to_source(user_dir = nil) 33 | if user_dir 34 | "#{user_dir}/.rvm/scripts/rvm" 35 | else 36 | if ::File.directory?("/etc/profile.d") 37 | "/etc/profile.d/rvm.sh" 38 | else 39 | "/etc/profile" 40 | end 41 | end 42 | end 43 | 44 | ## 45 | # Returns a shell command that is RVM-aware 46 | # 47 | # @param [String, #to_s] the shell command to be wrapped 48 | # @param [String] A user's home directory path if this is for a user or 49 | # nil if it is in a system context 50 | # @return [String] the command wrapped in RVM-initialized bash command 51 | def rvm_wrap_cmd(cmd, user_dir = nil) 52 | profile = find_profile_to_source(user_dir) 53 | %{bash -c "source #{profile} && #{cmd.gsub(/"/, '\"')}"} 54 | end 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /providers/default_ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Provider:: default_ruby 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include Chef::RVM::StringHelpers 23 | include Chef::RVM::EnvironmentHelpers 24 | 25 | def load_current_resource 26 | @rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string)) 27 | @gemset = select_gemset(new_resource.ruby_string) 28 | @ruby_string = @gemset.nil? ? @rubie : "#{@rubie}@#{@gemset}" 29 | @rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user) 30 | end 31 | 32 | action :create do 33 | next if skip_ruby? 34 | 35 | # ensure ruby is installed and gemset exists (if specified) 36 | unless env_exists?(@ruby_string) 37 | e = rvm_environment @ruby_string do 38 | user new_resource.user 39 | action :nothing 40 | end 41 | e.run_action(:create) 42 | end 43 | 44 | Chef::Log.info("Setting default ruby to rvm_ruby[#{@ruby_string}]") 45 | @rvm_env.rvm :use, @ruby_string, :default => true 46 | new_resource.updated_by_last_action(true) 47 | end 48 | 49 | private 50 | 51 | def skip_ruby? 52 | if @rubie.nil? 53 | Chef::Log.warn("#{self.class.name}: RVM ruby string `#{@rubie}' " + 54 | "is not known. Use `rvm list known` to get a full list.") 55 | true 56 | elsif ruby_default?(@ruby_string) 57 | Chef::Log.debug("#{self.class.name}: `#{@ruby_string}' is already default, " + 58 | "so skipping") 59 | true 60 | else 61 | false 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /libraries/chef_rvm_string_helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: Chef::RVM::StringHelpers 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | class Chef 23 | module RVM 24 | module StringHelpers 25 | ## 26 | # Filters out any gemset declarations in an RVM Ruby string 27 | # 28 | # @param [String, #to_s] the RVM Ruby string 29 | # @return [String] the Ruby string, minus gemset 30 | def select_ruby(ruby_string) 31 | ruby_string.split('@').first 32 | end 33 | 34 | ## 35 | # Filters out any Ruby declaration in an RVM Ruby string 36 | # 37 | # @param [String, #to_s] the RVM Ruby string 38 | # @return [String] the gemset string, minus Ruby or nil if no gemset given 39 | def select_gemset(ruby_string) 40 | if ruby_string.include?('@') 41 | ruby_string.split('@').last 42 | else 43 | nil 44 | end 45 | end 46 | 47 | ## 48 | # Sanitizes a Ruby string so that it's more normalized. 49 | # 50 | # @param [String, #to_s] an RVM Ruby string 51 | # @param [String] a specific user RVM or nil for system-wide 52 | # @return [String] a fully qualified RVM Ruby string 53 | def normalize_ruby_string(ruby_string, user = new_resource.user, patch = new_resource.patch) 54 | return "system" if ruby_string == "system" 55 | fetched_ruby_string = StringCache.fetch(ruby_string, user) 56 | return "#{fetched_ruby_string} --patch #{patch}" if patch 57 | fetched_ruby_string 58 | end 59 | end 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /providers/environment.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Provider:: environment 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include Chef::RVM::StringHelpers 23 | include Chef::RVM::RubyHelpers 24 | include Chef::RVM::GemsetHelpers 25 | 26 | def load_current_resource 27 | @rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string)) 28 | @gemset = select_gemset(new_resource.ruby_string) 29 | @ruby_string = @gemset.nil? ? @rubie : "#{@rubie}@#{@gemset}" 30 | @rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user) 31 | end 32 | 33 | action :create do 34 | next if skip_environment? 35 | 36 | if @gemset 37 | gemset_resource :create 38 | else 39 | ruby_resource :install 40 | end 41 | end 42 | 43 | private 44 | 45 | def skip_environment? 46 | if @rubie.nil? 47 | Chef::Log.warn("#{self.class.name}: RVM ruby string `#{@rubie}' " + 48 | "is not known. Use `rvm list known` to get a full list.") 49 | true 50 | else 51 | false 52 | end 53 | end 54 | 55 | def gemset_resource(exec_action) 56 | # ensure gemset is created, if specified 57 | unless gemset_exists?(:ruby => @rubie, :gemset => @gemset) 58 | r = rvm_gemset @ruby_string do 59 | user new_resource.user 60 | action :nothing 61 | end 62 | r.run_action(exec_action) 63 | new_resource.updated_by_last_action(true) if r.updated_by_last_action? 64 | end 65 | end 66 | 67 | def ruby_resource(exec_action) 68 | # ensure ruby is installed 69 | unless ruby_installed?(@rubie) 70 | r = rvm_ruby @rubie do 71 | user new_resource.user 72 | action :nothing 73 | end 74 | r.run_action(exec_action) 75 | new_resource.updated_by_last_action(true) if r.updated_by_last_action? 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /providers/wrapper.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Provider:: wrapper 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include Chef::RVM::StringHelpers 23 | include Chef::RVM::EnvironmentHelpers 24 | 25 | def load_current_resource 26 | @rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string)) 27 | @gemset = select_gemset(new_resource.ruby_string) 28 | @ruby_string = @gemset.nil? ? @rubie : "#{@rubie}@#{@gemset}" 29 | @rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user) 30 | 31 | if new_resource.binary.nil? 32 | @binaries = new_resource.binaries || [] 33 | else 34 | @binaries = [ new_resource.binary ] || [] 35 | end 36 | end 37 | 38 | action :create do 39 | # ensure ruby is installed and gemset exists 40 | unless env_exists?(@ruby_string) 41 | e = rvm_environment @ruby_string do 42 | user new_resource.user 43 | action :nothing 44 | end 45 | e.run_action(:create) 46 | end 47 | 48 | @rvm_env.use @ruby_string 49 | 50 | @binaries.each { |b| create_wrapper(b) } 51 | end 52 | 53 | private 54 | 55 | def create_wrapper(bin) 56 | full_bin = "#{new_resource.prefix}_#{bin}" 57 | resource_name = "rvm_wrapper[#{full_bin}::#{@ruby_string}]" 58 | script = ::File.join(@rvm_env.config["rvm_path"], "bin", full_bin) 59 | 60 | if ::File.exists?(script) 61 | Chef::Log.debug("#{resource_name} already exists, so updating") 62 | else 63 | Chef::Log.info("Creating #{resource_name}") 64 | end 65 | 66 | if @rvm_env.wrapper @ruby_string, new_resource.prefix, bin 67 | Chef::Log.debug("Creation/Update of #{resource_name} was successful.") 68 | new_resource.updated_by_last_action(true) 69 | else 70 | Chef::Log.warn("Failed to create/update #{resource_name}.") 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /test/unit/chef/rvm/recipe_helpers_spec.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: Chef::RVM::RecipeHelpers 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2013, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | def require_library(name) 23 | require File.expand_path(File.join( 24 | File.dirname(__FILE__), '../../../../libraries', "#{name}.rb" 25 | )) 26 | end 27 | 28 | require 'minitest/autorun' 29 | require_library 'chef_rvm_recipe_helpers' 30 | 31 | class Dummy 32 | include Chef::RVM::RecipeHelpers 33 | end 34 | 35 | describe 'Chef::RVM::RecipeHelpers' do 36 | 37 | subject do 38 | Dummy.new 39 | end 40 | 41 | describe '.build_script_flags' do 42 | 43 | it 'sets branch and version flags' do 44 | subject.build_script_flags("stable", "head"). 45 | must_equal " -s -- --branch stable --version head" 46 | end 47 | 48 | it 'sets a missing branch to "head"' do 49 | subject.build_script_flags("cool"). 50 | must_equal " -s -- --branch cool --version head" 51 | end 52 | 53 | it 'only emits version with branch=stable and version=x.y.z' do 54 | subject.build_script_flags("stable", "1.2.3"). 55 | must_equal " -s -- --version 1.2.3" 56 | end 57 | 58 | it 'only emits version with branch=master and version=x.y.z' do 59 | subject.build_script_flags("master", "4.5.6"). 60 | must_equal " -s -- --version 4.5.6" 61 | end 62 | 63 | it 'only emits version with branch=none and version=x.y.z' do 64 | subject.build_script_flags("none", "7.3.5"). 65 | must_equal " -s -- --version 7.3.5" 66 | end 67 | 68 | it 'emits version and branch with branch not stable|master and version=x.y.z' do 69 | subject.build_script_flags("foo/bar", "0.9.8"). 70 | must_equal " -s -- --branch foo/bar --version 0.9.8" 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name "rvm" 2 | maintainer "Fletcher Nichol" 3 | maintainer_email "fnichol@nichol.ca" 4 | license "Apache 2.0" 5 | description "Manages system-wide and per-user RVMs and manages installed Rubies. Several lightweight resources and providers (LWRP) are also defined.Installs and manages RVM. Includes several LWRPs." 6 | long_description "Please refer to README.md (it's long)." 7 | version "0.9.1" 8 | 9 | recipe "rvm", "Installs the RVM gem and initializes Chef to use the Lightweight Resources and Providers (LWRPs). Use this recipe explicitly if you only want access to the LWRPs provided." 10 | recipe "rvm::system_install", "Installs the RVM codebase system-wide (that is, into /usr/local/rvm). This recipe includes *default*. Use this recipe by itself if you want RVM installed system-wide but want to handle installing Rubies, invoking LWRPs, etc.." 11 | recipe "rvm::system", "Installs the RVM codebase system-wide (that is, into /usr/local/rvm) and installs Rubies, global gems, and specific gems driven off attribute metadata. This recipe includes *default* and *system_install*. Use this recipe by itself if you want RVM system-wide with Rubies installed, etc." 12 | recipe "rvm::user_install", "Installs the RVM codebase for a list of users (selected from the node['rvm']['user_installs'] hash). This recipe includes *default*. Use this recipe by itself if you want RVM installed for specific users in isolation but want each user to handle installing Rubies, invoking LWRPs, etc." 13 | recipe "rvm::user", "Installs the RVM codebase for a list of users (selected from the node['rvm']['user_installs'] hash) and installs Rubies, global gems, and specific gems driven off attribute metadata. This recipe includes *default* and *user_install*. Use this recipe by itself if you want RVM installed for specific users in isolation with Rubies installed, etc." 14 | recipe "rvm::vagrant", "An optional recipe to help if running in a Vagrant virtual machine" 15 | recipe "rvm::gem_package", "An experimental recipe that patches the gem_package resource" 16 | 17 | # provides chef_gem resource to chef <= 0.10.8 and fixes for chef < 10.12.0 18 | depends "chef_gem" 19 | 20 | supports "debian" 21 | supports "ubuntu" 22 | supports "suse" 23 | supports "centos" 24 | supports "amazon" 25 | supports "redhat" 26 | supports "fedora" 27 | supports "mac_os_x" 28 | supports "mac_os_x_server" 29 | 30 | # if using jruby, java is required on system 31 | recommends "java" 32 | -------------------------------------------------------------------------------- /libraries/chef_rvm_gemset_helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: Chef::RVM::GemsetHelpers 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | class Chef 23 | module RVM 24 | module GemsetHelpers 25 | ## 26 | # Lists all gemsets for a given RVM Ruby. 27 | # 28 | # **Note** that these values are cached for lookup speed. To flush these 29 | # values and force an update, call #update_installed_gemsets. 30 | # 31 | # @param [String, #to_s] the RVM Ruby string 32 | # @return [Array] a cached list of gemset names 33 | def installed_gemsets(rubie) 34 | @installed_gemsets = Hash.new if @installed_gemsets.nil? 35 | @installed_gemsets[rubie] ||= update_installed_gemsets(rubie) 36 | end 37 | 38 | ## 39 | # Updates the list of all gemsets for a given RVM Ruby on the system 40 | # 41 | # @param [String, #to_s] the RVM Ruby string 42 | # @return [Array] the current list of gemsets 43 | def update_installed_gemsets(rubie) 44 | original_rubie = @rvm_env.environment_name 45 | @rvm_env.use rubie 46 | 47 | @installed_gemsets ||= {} 48 | @installed_gemsets[rubie] = @rvm_env.gemset_list 49 | @rvm_env.use original_rubie if original_rubie != rubie 50 | @installed_gemsets[rubie] 51 | end 52 | 53 | ## 54 | # Determines whether or not a gemset exists for a given Ruby 55 | # 56 | # @param [Hash] the options to query a gemset with 57 | # @option opts [String] :ruby the Ruby the query within 58 | # @option opts [String] :gemset the gemset to look for 59 | def gemset_exists?(opts={}) 60 | return false if opts[:ruby].nil? || opts[:gemset].nil? 61 | return false unless ruby_installed?(opts[:ruby]) 62 | 63 | installed_gemsets(opts[:ruby]).include?(opts[:gemset]) 64 | end 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Attributes:: default 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2010, 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | # ruby that will get installed and set to `rvm use default`. 23 | default['rvm']['default_ruby'] = "ruby-1.9.3-p327" 24 | default['rvm']['user_default_ruby'] = "ruby-1.9.3-p327" 25 | 26 | # list of additional rubies that will be installed 27 | default['rvm']['rubies'] = [] 28 | default['rvm']['user_rubies'] = [] 29 | 30 | # list of gems to be installed in global gemset of all rubies 31 | _global_gems_ = [ 32 | { 'name' => 'bundler' } 33 | ] 34 | default['rvm']['global_gems'] = _global_gems_.dup 35 | default['rvm']['user_global_gems'] = _global_gems_.dup 36 | 37 | # hash of gemsets and their list of additional gems to be installed. 38 | default['rvm']['gems'] = Hash.new 39 | default['rvm']['user_gems'] = Hash.new 40 | 41 | # hash of rvmrc options 42 | default['rvm']['rvmrc'] = Hash.new 43 | 44 | # a list of user hashes, each an isolated per-user RVM installation 45 | default['rvm']['user_installs'] = [] 46 | 47 | # system-wide installer options 48 | default['rvm']['installer_url'] = "https://get.rvm.io" 49 | default['rvm']['branch'] = "stable" 50 | default['rvm']['version'] = "head" 51 | default['rvm']['upgrade'] = "none" 52 | 53 | # extra system-wide tunables 54 | default['rvm']['root_path'] = "/usr/local/rvm" 55 | default['rvm']['group_id'] = 'default' 56 | default['rvm']['group_users'] = [] 57 | 58 | # default rvm_gem_options (skip rdoc/ri generation) 59 | default['rvm']['rvm_gem_options'] = "--no-rdoc --no-ri" 60 | 61 | # a hook to disable installing any default/additional rubies 62 | default['rvm']['install_rubies'] = "true" 63 | default['rvm']['user_install_rubies'] = "true" 64 | 65 | case platform 66 | when "redhat","centos","fedora","scientific","amazon" 67 | node.set['rvm']['install_pkgs'] = %w{sed grep tar gzip bzip2 bash curl git} 68 | default['rvm']['user_home_root'] = '/home' 69 | when "debian","ubuntu","suse" 70 | node.set['rvm']['install_pkgs'] = %w{sed grep tar gzip bzip2 bash curl git-core} 71 | default['rvm']['user_home_root'] = '/home' 72 | when "mac_os_x", "mac_os_x_server" 73 | node.set['rvm']['install_pkgs'] = %w{git} 74 | default['rvm']['user_home_root'] = '/Users' 75 | end 76 | -------------------------------------------------------------------------------- /libraries/chef_rvm_ruby_helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: Chef::RVM::RubyHelpers 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | class Chef 23 | module RVM 24 | module RubyHelpers 25 | ## 26 | # Lists all installed RVM Rubies on the system. 27 | # 28 | # **Note** that these values are cached for lookup speed. To flush these 29 | # values and force an update, call #update_installed_rubies. 30 | # 31 | # @return [Array] the cached list of currently installed RVM Rubies 32 | def installed_rubies 33 | @installed_rubies ||= update_installed_rubies 34 | end 35 | 36 | ## 37 | # Updates the list of all installed RVM Rubies on the system 38 | # 39 | # @return [Array] the list of currently installed RVM Rubies 40 | def update_installed_rubies 41 | @installed_rubies = @rvm_env.list_strings 42 | @installed_rubies 43 | end 44 | 45 | ## 46 | # Determines whether or not the given Ruby is already installed 47 | # 48 | # @param [String, #to_s] the RVM Ruby string 49 | # @return [Boolean] is this Ruby installed? 50 | def ruby_installed?(rubie) 51 | ! installed_rubies.select { |r| r.end_with?(rubie) }.empty? 52 | end 53 | 54 | ## 55 | # Fetches the current default Ruby string, potentially with gemset 56 | # 57 | # @return [String] the RVM Ruby string, nil if none is set 58 | def current_ruby_default 59 | @rvm_env.list_default 60 | end 61 | 62 | ## 63 | # Determines whether or not the given Ruby is the default one 64 | # 65 | # @param [String, #to_s] the RVM Ruby string 66 | # @return [Boolean] is this Ruby the default one? 67 | def ruby_default?(rubie) 68 | current_default = current_ruby_default 69 | 70 | if current_default.nil? 71 | if rubie == "system" 72 | return true 73 | else 74 | return false 75 | end 76 | end 77 | 78 | current_default.start_with?(rubie) 79 | end 80 | 81 | ## 82 | # Determines whether or not the given Ruby could be considered the 83 | # system Ruby. 84 | # 85 | # @param [String, #to_s] the RVM Ruby string 86 | # @return [Boolean] is this Ruby string the a system Ruby? 87 | def system_ruby?(rubie) 88 | return true if rubie.nil? # nil should be system 89 | return true if rubie.empty? # an empty string should be system 90 | return true if rubie == "system" # keyword system should be system 91 | return false # anything else does not represent system 92 | end 93 | end 94 | end 95 | end 96 | -------------------------------------------------------------------------------- /libraries/rvm_shell_chef_wrapper.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: RVM::Shell::ChefWrapper 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | def create_rvm_shell_chef_wrapper 23 | require 'chef/mixin/command' 24 | 25 | klass = Class.new(::RVM::Shell::AbstractWrapper) do 26 | include Chef::Mixin::Command 27 | 28 | attr_accessor :current 29 | 30 | def initialize(user = nil, sh = 'bash -l', &setup_block) 31 | @user = user 32 | super(sh, &setup_block) 33 | end 34 | 35 | # Runs a given command in the current shell. 36 | # Defaults the command to true if empty. 37 | def run_command(command) 38 | command = "true" if command.to_s.strip.empty? 39 | with_shell_instance do 40 | Chef::Log.debug("RVM::Shell::ChefWrapper executing: " + 41 | "[#{wrapped_command(command)}]") 42 | stdin.puts wrapped_command(command) 43 | stdin.close 44 | out, err = stdout.read, stderr.read 45 | out, status, _ = raw_stdout_to_parts(out) 46 | return status, out, err 47 | end 48 | end 49 | 50 | # Runs a command, ensuring no output is collected. 51 | def run_command_silently(command) 52 | with_shell_instance do 53 | Chef::Log.debug("RVM::Shell::ChefWrapper silently executing: " + 54 | "[#{wrapped_command(command)}]") 55 | stdin.puts silent_command(command) 56 | end 57 | end 58 | 59 | protected 60 | 61 | # yields stdio, stderr and stdin for a shell instance. 62 | # If there isn't a current shell instance, it will create a new one. 63 | # In said scenario, it will also cleanup once it is done. 64 | def with_shell_instance(&blk) 65 | no_current = @current.nil? 66 | if no_current 67 | Chef::Log.debug("RVM::Shell::ChefWrapper subprocess executing with " + 68 | "environment of: [#{shell_params.inspect}].") 69 | @current = popen4(self.shell_executable, shell_params) 70 | invoke_setup! 71 | end 72 | yield 73 | ensure 74 | @current = nil if no_current 75 | end 76 | 77 | # Direct access to each of the named descriptors 78 | def stdin; @current[1]; end 79 | def stdout; @current[2]; end 80 | def stderr; @current[3]; end 81 | 82 | def shell_params 83 | if @user.nil? 84 | Hash.new 85 | else 86 | { 87 | :user => @user, 88 | :environment => { 89 | 'USER' => @user, 90 | 'HOME' => Etc.getpwnam(@user).dir 91 | } 92 | } 93 | end 94 | end 95 | end 96 | ::RVM::Shell.const_set('ChefWrapper', klass) 97 | 98 | ::RVM::Shell.default_wrapper = ::RVM::Shell::ChefWrapper 99 | end 100 | -------------------------------------------------------------------------------- /providers/global_gem.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Provider:: global_gem 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include Chef::RVM::RubyHelpers 23 | 24 | def load_current_resource 25 | @rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user) 26 | end 27 | 28 | [:install, :upgrade, :remove, :purge].each do |exec_action| 29 | action exec_action do 30 | # add gem entry into global.gems 31 | update_global_gems_file exec_action 32 | 33 | # install gem in all rubies in global gemsets 34 | installed_rubies.each do |rubie| 35 | gem_package_wrapper exec_action, "#{rubie}@global" 36 | end 37 | end 38 | end 39 | 40 | private 41 | 42 | ## 43 | # Wraps the rvm_gem resource 44 | # 45 | # @param [Symbol] action to be performed with gem_package provider 46 | # @param [optional, String, #to_s] the fully qualifed rvm string 47 | def gem_package_wrapper(exec_action, ruby_global_gemset) 48 | g = rvm_gem new_resource.package_name do 49 | ruby_string ruby_global_gemset 50 | source new_resource.source if new_resource.source 51 | options new_resource.options if new_resource.options 52 | version new_resource.version if new_resource.version 53 | gem_binary new_resource.gem_binary if new_resource.gem_binary 54 | user new_resource.user 55 | action :nothing 56 | end 57 | g.run_action(exec_action) 58 | new_resource.updated_by_last_action(true) if g.updated_by_last_action? 59 | end 60 | 61 | ## 62 | # Updates global.gems file to create or remove a gem entry 63 | # 64 | # @oaram [Symbol] action to :create or :remove the gem from the file 65 | def update_global_gems_file(exec_action) 66 | gem = if new_resource.version 67 | "#{new_resource.package_name} -v#{new_resource.version}" 68 | else 69 | new_resource.package_name 70 | end 71 | user_dir = Etc.getpwnam(new_resource.user).dir if new_resource.user 72 | global_gems_file = if new_resource.user 73 | "#{user_dir}/.rvm/gemsets/global.gems" 74 | else 75 | "#{node['rvm']['root_path']}/gemsets/global.gems" 76 | end 77 | 78 | if [:install, :upgrade].include?(exec_action) 79 | e = execute "Add #{gem} to #{global_gems_file}" do 80 | if new_resource.user 81 | user new_resource.user 82 | group Etc.getpwnam(new_resource.user).gid 83 | environment ({ 'USER' => new_resource.user, 'HOME' => user_dir }) 84 | else 85 | user "root" 86 | group "rvm" 87 | end 88 | 89 | command %{echo "#{gem}" >> "#{global_gems_file}"} 90 | action :nothing 91 | 92 | not_if %{grep -q "^#{gem}" "#{global_gems_file}"} 93 | end 94 | e.run_action(:run) 95 | new_resource.updated_by_last_action(true) if e.updated_by_last_action? 96 | end 97 | end 98 | -------------------------------------------------------------------------------- /libraries/chef_rvm_string_cache.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: Chef::RVM::StringCache 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | require 'chef/mixin/command' 23 | 24 | class Chef 25 | module RVM 26 | module ShellHelpers 27 | # stub to satisfy StringCache (library load order not guarenteed) 28 | end 29 | 30 | class StringCache 31 | class << self 32 | include Chef::Mixin::Command 33 | include Chef::RVM::ShellHelpers 34 | end 35 | 36 | ## 37 | # Returns a fully qualified RVM Ruby string for the given input string 38 | # 39 | # @param [String] a string that can interpreted by RVM 40 | # @param [String] the username if this is for a user install or nil if 41 | # it is a system install 42 | # @return [String] a fully qualified RVM Ruby string 43 | def self.fetch(str, user = nil) 44 | @@strings ||= Hash.new 45 | rvm_install = user || "system" 46 | @@strings[rvm_install] ||= Hash.new 47 | 48 | return @@strings[rvm_install][str] if @@strings[rvm_install].has_key?(str) 49 | 50 | result = canonical_ruby_string(str, user) 51 | # cache everything except default environment 52 | if str == 'default' 53 | result 54 | else 55 | @@strings[rvm_install][str] = result 56 | end 57 | end 58 | 59 | protected 60 | 61 | def self.canonical_ruby_string(str, user) 62 | Chef::Log.debug("Fetching canonical RVM string for: #{str} " + 63 | "(#{user || 'system'})") 64 | if user 65 | user_dir = Etc.getpwnam(user).dir 66 | else 67 | user_dir = nil 68 | end 69 | 70 | cmd = ["source #{find_profile_to_source(user_dir)}", 71 | "rvm_ruby_string='#{str}'", "__rvm_ruby_string", 72 | "echo $rvm_ruby_string"].join(" && ") 73 | pid, stdin, stdout, stderr = popen4('bash', shell_params(user, user_dir)) 74 | stdin.puts(cmd) 75 | stdin.close 76 | 77 | result = stdout.read.split('\n').first.chomp 78 | if result =~ /^-/ # if the result has a leading dash, value is bogus 79 | Chef::Log.warn("Could not determine canonical RVM string for: #{str} " + 80 | "(#{user || 'system'})") 81 | nil 82 | else 83 | Chef::Log.debug("Canonical RVM string is: #{str} => #{result} " + 84 | "(#{user || 'system'})") 85 | result 86 | end 87 | end 88 | 89 | def self.shell_params(user, user_dir) 90 | if user 91 | { 92 | :user => user, 93 | :environment => { 94 | 'USER' => user, 95 | 'HOME' => user_dir 96 | } 97 | } 98 | else 99 | Hash.new 100 | end 101 | end 102 | end 103 | end 104 | end 105 | -------------------------------------------------------------------------------- /providers/shell.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Provider:: shell 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include Chef::RVM::StringHelpers 23 | include Chef::RVM::EnvironmentHelpers 24 | include Chef::RVM::ShellHelpers 25 | 26 | def load_current_resource 27 | @user_rvm = user_installed_rvm? ? new_resource.user : nil 28 | @rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string), @user_rvm) 29 | @gemset = select_gemset(new_resource.ruby_string) 30 | @ruby_string = @gemset.nil? ? @rubie : "#{@rubie}@#{@gemset}" 31 | @rvm_env = ::RVM::ChefUserEnvironment.new(@user_rvm) 32 | end 33 | 34 | action :run do 35 | user_rvm = @user_rvm 36 | 37 | # ensure ruby is installed and gemset exists 38 | unless env_exists?(@ruby_string) 39 | e = rvm_environment @ruby_string do 40 | user user_rvm 41 | action :nothing 42 | end 43 | e.run_action(:create) 44 | end 45 | 46 | script_wrapper :run 47 | end 48 | 49 | private 50 | 51 | ## 52 | # Wraps the script resource for RVM-dependent code. 53 | # 54 | # @param [Symbol] action to be performed with gem_package provider 55 | def script_wrapper(exec_action) 56 | profile = find_profile_to_source 57 | 58 | script_code = <<-CODE 59 | if [ -s "${HOME}/.rvm/scripts/rvm" ]; then 60 | source "${HOME}/.rvm/scripts/rvm" 61 | elif [ -s "#{profile}" ]; then 62 | source "#{profile}" 63 | fi 64 | 65 | rvm use #{@ruby_string} 66 | 67 | #{new_resource.code} 68 | CODE 69 | 70 | if new_resource.user 71 | user_rvm = user_installed_rvm? 72 | user_home = user_dir 73 | end 74 | 75 | s = script new_resource.name do 76 | interpreter "bash" 77 | 78 | if new_resource.user 79 | user new_resource.user 80 | if user_rvm && new_resource.environment 81 | environment({ 'USER' => new_resource.user, 'HOME' => user_home }.merge( 82 | new_resource.environment)) 83 | elsif user_rvm 84 | environment({ 'USER' => new_resource.user, 'HOME' => user_home }) 85 | end 86 | end 87 | 88 | code script_code 89 | creates new_resource.creates if new_resource.creates 90 | cwd new_resource.cwd if new_resource.cwd 91 | group new_resource.group if new_resource.group 92 | path new_resource.path if new_resource.path 93 | returns new_resource.returns if new_resource.returns 94 | timeout new_resource.timeout if new_resource.timeout 95 | umask new_resource.umask if new_resource.umask 96 | action :nothing 97 | end 98 | s.run_action(exec_action) 99 | new_resource.updated_by_last_action(true) if s.updated_by_last_action? 100 | end 101 | 102 | ## 103 | # Whether or not the user has an isolated RVM installation 104 | # 105 | # @return [true,false] does the user have RVM installed for themselves? 106 | def user_installed_rvm? 107 | return false unless new_resource.user 108 | 109 | ::File.exists?("#{user_dir}/.rvm/VERSION") 110 | end 111 | 112 | ## 113 | # Determines the user's home directory 114 | # 115 | # @return [String] the path to the user's home directory 116 | def user_dir 117 | return nil unless new_resource.user 118 | 119 | Etc.getpwnam(new_resource.user).dir 120 | end 121 | -------------------------------------------------------------------------------- /providers/gemset.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Provider:: gemset 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include Chef::RVM::StringHelpers 23 | include Chef::RVM::RubyHelpers 24 | include Chef::RVM::GemsetHelpers 25 | 26 | def load_current_resource 27 | if new_resource.ruby_string 28 | @rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string)) 29 | @gemset = new_resource.gemset 30 | else 31 | @rubie = normalize_ruby_string(select_ruby(new_resource.gemset)) 32 | @gemset = select_gemset(new_resource.gemset) 33 | end 34 | @ruby_string = "#{@rubie}@#{@gemset}" 35 | @rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user) 36 | end 37 | 38 | action :create do 39 | unless ruby_installed?(@rubie) 40 | r = rvm_ruby @rubie do 41 | user new_resource.user 42 | action :nothing 43 | end 44 | r.run_action(:install) 45 | end 46 | 47 | if gemset_exists?(:ruby => @rubie, :gemset => @gemset) 48 | Chef::Log.debug("rvm_gemset[#{@ruby_string}] already exists, so skipping") 49 | else 50 | Chef::Log.info("Creating rvm_gemset[#{@ruby_string}]") 51 | 52 | @rvm_env.use @rubie 53 | if @rvm_env.gemset_create @gemset 54 | update_installed_gemsets(@rubie) 55 | Chef::Log.debug("Creation of rvm_gemset[#{@ruby_string}] was successful.") 56 | else 57 | Chef::Log.warn("Failed to create rvm_gemset[#{@ruby_string}].") 58 | end 59 | 60 | new_resource.updated_by_last_action(true) 61 | end 62 | end 63 | 64 | action :delete do 65 | if gemset_exists?(:ruby => @rubie, :gemset => @gemset) 66 | Chef::Log.info("Deleting rvm_gemset[#{@ruby_string}]") 67 | 68 | @rvm_env.use @rubie 69 | if @rvm_env.gemset_delete @gemset 70 | update_installed_gemsets(@rubie) 71 | Chef::Log.debug("Deletion of rvm_gemset[#{@ruby_string}] was successful.") 72 | new_resource.updated_by_last_action(true) 73 | else 74 | Chef::Log.warn("Failed to delete rvm_gemset[#{@ruby_string}].") 75 | end 76 | else 77 | Chef::Log.debug("rvm_gemset[#{@ruby_string}] does not exist, so skipping") 78 | end 79 | end 80 | 81 | action :empty do 82 | if gemset_exists?(:ruby => @rubie, :gemset => @gemset) 83 | Chef::Log.info("Emptying rvm_gemset[#{@ruby_string}]") 84 | 85 | @rvm_env.use @ruby_string 86 | if @rvm_env.gemset_empty 87 | update_installed_gemsets(@rubie) 88 | Chef::Log.debug("Emptying of rvm_gemset[#{@ruby_string}] was successful.") 89 | new_resource.updated_by_last_action(true) 90 | else 91 | Chef::Log.warn("Failed to empty rvm_gemset[#{@ruby_string}].") 92 | end 93 | else 94 | Chef::Log.debug("rvm_gemset[#{@ruby_string}] does not exist, so skipping") 95 | end 96 | end 97 | 98 | action :update do 99 | Chef::Log.info("Updating rvm_gemset[#{@ruby_string}]") 100 | 101 | # create gemset if it doesn't exist 102 | unless gemset_exists?(:ruby => @rubie, :gemset => @gemset) 103 | c = rvm_gemset @ruby_string do 104 | user new_resource.user 105 | action :nothing 106 | end 107 | c.run_action(:create) 108 | end 109 | 110 | @rvm_env.use @ruby_string 111 | if @rvm_env.gemset_update 112 | update_installed_gemsets(@rubie) 113 | Chef::Log.debug("Updating of rvm_gemset[#{@ruby_string}] was successful.") 114 | new_resource.updated_by_last_action(true) 115 | else 116 | Chef::Log.warn("Failed to update rvm_gemset[#{@ruby_string}].") 117 | end 118 | end 119 | -------------------------------------------------------------------------------- /providers/ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Provider:: ruby 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | include Chef::RVM::StringHelpers 23 | include Chef::RVM::RubyHelpers 24 | 25 | def load_current_resource 26 | @rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string)) 27 | @ruby_string = new_resource.ruby_string 28 | @rvm_env = ::RVM::ChefUserEnvironment.new( 29 | new_resource.user, "default", 30 | :rvm_rubygems_version => new_resource.rubygems_version, 31 | :source_environment => false 32 | ) 33 | end 34 | 35 | action :install do 36 | next if skip_ruby? 37 | 38 | if ruby_installed?(@ruby_string) 39 | Chef::Log.debug("rvm_ruby[#{@rubie}] is already installed, so skipping") 40 | else 41 | install_start = Time.now 42 | install_options = {:rvm_by_path => true} 43 | install_options[:patch] = new_resource.patch if new_resource.patch 44 | 45 | install_ruby_dependencies @rubie 46 | 47 | Chef::Log.info("Building rvm_ruby[#{@rubie}], this could take awhile...") 48 | 49 | if @rvm_env.install(@rubie, install_options) 50 | Chef::Log.info("Installation of rvm_ruby[#{@rubie}] was successful.") 51 | @rvm_env.use @rubie 52 | update_installed_rubies 53 | new_resource.updated_by_last_action(true) 54 | 55 | Chef::Log.info("Importing initial gemsets for rvm_ruby[#{@rubie}]") 56 | if @rvm_env.gemset_initial 57 | Chef::Log.debug("Initial gemsets for rvm_ruby[#{@rubie}] are installed") 58 | else 59 | Chef::Log.warn( 60 | "Failed to install initial gemsets for rvm_ruby[#{@rubie}] ") 61 | end 62 | else 63 | Chef::Log.warn("Failed to install rvm_ruby[#{@rubie}]. " + 64 | "Check logs in #{::RVM.path}/log/#{@rubie}") 65 | end 66 | 67 | Chef::Log.info("rvm_ruby[#{@rubie}] build time was " + 68 | "#{(Time.now - install_start)/60.0} minutes.") 69 | end 70 | end 71 | 72 | action :uninstall do 73 | next if skip_ruby? 74 | 75 | if ruby_installed?(@rubie) 76 | Chef::Log.info("Uninstalling rvm_ruby[#{@rubie}]") 77 | 78 | if @rvm_env.uninstall(@rubie, :rvm_by_path => true) 79 | update_installed_rubies 80 | Chef::Log.debug("Uninstallation of rvm_ruby[#{@rubie}] was successful.") 81 | new_resource.updated_by_last_action(true) 82 | else 83 | Chef::Log.warn("Failed to uninstall rvm_ruby[#{@rubie}]. " + 84 | "Check logs in #{::RVM.path}/log/#{@rubie}") 85 | end 86 | else 87 | Chef::Log.debug("rvm_ruby[#{@rubie}] was not installed, so skipping") 88 | end 89 | end 90 | 91 | action :remove do 92 | next if skip_ruby? 93 | 94 | if ruby_installed?(@rubie) 95 | Chef::Log.info("Removing rvm_ruby[#{@rubie}]") 96 | 97 | if @rvm_env.remove(@rubie, :rvm_by_path => true) 98 | update_installed_rubies 99 | Chef::Log.debug("Removal of rvm_ruby[#{@rubie}] was successful.") 100 | new_resource.updated_by_last_action(true) 101 | else 102 | Chef::Log.warn("Failed to remove rvm_ruby[#{@rubie}]. " + 103 | "Check logs in #{::RVM.path}/log/#{@rubie}") 104 | end 105 | else 106 | Chef::Log.debug("rvm_ruby[#{@rubie}] was not installed, so skipping") 107 | end 108 | end 109 | 110 | private 111 | 112 | def skip_ruby? 113 | if @rubie.nil? 114 | Chef::Log.warn("#{self.class.name}: RVM ruby string `#{@rubie}' " + 115 | "is not known. Use `rvm list known` to get a full list.") 116 | true 117 | else 118 | false 119 | end 120 | end 121 | 122 | ## 123 | # Installs any package dependencies needed by a given ruby 124 | # 125 | # @param [String, #to_s] the fully qualified RVM ruby string 126 | def install_ruby_dependencies(rubie) 127 | pkgs = [] 128 | case rubie 129 | when /^ruby-/, /^ree-/, /^rbx-/, /^kiji/ 130 | case node['platform'] 131 | when "debian","ubuntu" 132 | pkgs = %w{ build-essential openssl libreadline6 libreadline6-dev 133 | zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev 134 | sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev 135 | ncurses-dev automake libtool bison ssl-cert pkg-config libgdbm-dev libffi-dev} 136 | pkgs += %w{ subversion } if rubie =~ /^ruby-head$/ 137 | when "suse" 138 | pkgs = %w{ gcc-c++ patch zlib zlib-devel libffi-devel 139 | sqlite3-devel libxml2-devel libxslt-devel } 140 | if node['platform_version'].to_f >= 11.0 141 | pkgs += %w{ libreadline5 readline-devel libopenssl-devel } 142 | else 143 | pkgs += %w{ readline readline-devel openssl-devel } 144 | end 145 | pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/ 146 | when "centos","redhat","fedora","scientific","amazon" 147 | pkgs = %w{ gcc-c++ patch readline readline-devel zlib zlib-devel 148 | libyaml-devel libffi-devel openssl-devel 149 | make bzip2 autoconf automake libtool bison 150 | libxml2 libxml2-devel libxslt libxslt-devel } 151 | pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/ 152 | end 153 | when /^jruby/ 154 | begin 155 | resource_collection.find("ruby_block[update-java-alternatives]"). 156 | run_action(:create) 157 | rescue Chef::Exceptions::ResourceNotFound 158 | Chef::Log.debug( 159 | "java cookbook not loaded or not on ubuntu/debian, so skipping") 160 | end 161 | 162 | # TODO: need to figure out how to pull in java recipe only when needed. For 163 | # now, users of jruby will have to add the "java" recipe to their run_list. 164 | #include_recipe "java" 165 | case node['platform'] 166 | when "debian","ubuntu" 167 | pkgs += %w{ g++ ant } 168 | end 169 | end 170 | 171 | pkgs.each do |pkg| 172 | package pkg do 173 | action :nothing 174 | end.run_action(:install) 175 | end 176 | end 177 | -------------------------------------------------------------------------------- /libraries/rvm_rubygems_package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Provider:: Chef::Provider::Package::RVMRubygems 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | class Chef 23 | module RVM 24 | module ShellHelpers 25 | # stub to satisfy RVMRubygems (library load order not guarenteed) 26 | end 27 | module SetHelpers 28 | # stub to satisfy RVMRubygems (library load order not guarenteed) 29 | end 30 | end 31 | 32 | class Provider 33 | class Package 34 | class RVMRubygems < Chef::Provider::Package::Rubygems 35 | include Chef::RVM::ShellHelpers 36 | include Chef::RVM::SetHelpers 37 | 38 | class RVMGemEnvironment < AlternateGemEnvironment 39 | include Chef::RVM::ShellHelpers 40 | include Chef::RVM::SetHelpers 41 | 42 | attr_reader :ruby_strings, :user 43 | 44 | def initialize(gem_binary_location, ruby_strings, user = nil) 45 | super(gem_binary_location) 46 | @ruby_strings = ruby_strings 47 | @user = user 48 | end 49 | 50 | def gem_paths 51 | cmd = "rvm #{ruby_strings.join(',')} " 52 | cmd << "#{rvm_do(user)} #{@gem_binary_location} env gempath" 53 | 54 | if user 55 | user_dir = Etc.getpwnam(user).dir 56 | environment = { 'USER' => user, 'HOME' => user_dir } 57 | else 58 | user_dir = nil 59 | environment = nil 60 | end 61 | 62 | # shellout! is a fork/exec which won't work on windows 63 | shell_style_paths = shell_out!( 64 | rvm_wrap_cmd(cmd, user_dir), :env => environment).stdout 65 | # on windows, the path separator is semicolon 66 | paths = shell_style_paths.split( 67 | ::File::PATH_SEPARATOR).map { |path| path.strip } 68 | end 69 | 70 | def gem_platforms 71 | cmd = "rvm #{ruby_strings.join(',')} " 72 | cmd << "#{rvm_do(user)} #{@gem_binary_location} env" 73 | 74 | if user 75 | user_dir = Etc.getpwnam(user).dir 76 | environment = { 'USER' => user, 'HOME' => user_dir } 77 | else 78 | user_dir = nil 79 | environment = nil 80 | end 81 | 82 | gem_environment = shell_out!( 83 | rvm_wrap_cmd(cmd, user_dir), :env => environment).stdout 84 | if jruby = gem_environment[JRUBY_PLATFORM] 85 | ['ruby', Gem::Platform.new(jruby)] 86 | else 87 | Gem.platforms 88 | end 89 | end 90 | end 91 | 92 | def initialize(new_resource, run_context=nil) 93 | original_gem_binary = new_resource.gem_binary 94 | super 95 | new_resource.gem_binary("gem") unless original_gem_binary 96 | user = new_resource.respond_to?("user") ? new_resource.user : nil 97 | @gem_env = RVMGemEnvironment.new(gem_binary_path, ruby_strings, user) 98 | end 99 | 100 | ## 101 | # Determine the array of RVM ruby strings to use in this provider. 102 | # In most cases only a single string value will be specified, but 103 | # an array is always returned to account for multiple rubies. 104 | # 105 | # @return [Array] an array of RVM ruby strings 106 | def ruby_strings 107 | @ruby_strings ||= begin 108 | result = if new_resource.respond_to?("ruby_string") 109 | # the resource understands `.ruby_string' natively 110 | new_resource.ruby_string 111 | else 112 | # most likely the gem_package resource or another native one 113 | node['rvm']['gem_package']['rvm_string'] 114 | end 115 | 116 | # if the result is a String, then wrap in an Array, otherwise 117 | # return the array 118 | case result 119 | when String; [ result ] 120 | when Array; result 121 | end 122 | end 123 | end 124 | 125 | def install_package(name, version) 126 | # ensure each ruby is installed and gemset exists 127 | ruby_strings.each do |rubie| 128 | next if rubie == 'system' 129 | e = rvm_environment rubie do 130 | user gem_env.user if gem_env.user 131 | action :nothing 132 | end 133 | e.run_action(:create) 134 | end 135 | 136 | install_via_gem_command(name, version) 137 | true 138 | end 139 | 140 | def install_via_gem_command(name, version) 141 | # Handle installing from a local file. 142 | if source_is_remote? 143 | src = @new_resource.source && 144 | " --source=#{@new_resource.source} --source=http://rubygems.org" 145 | else 146 | name = @new_resource.source 147 | end 148 | 149 | cmd = %{rvm #{ruby_strings.join(',')} #{rvm_do(gem_env.user)} #{gem_binary_path}} 150 | cmd << %{ install #{name} -q --no-rdoc --no-ri -v "#{version}"} 151 | cmd << %{#{src}#{opts}} 152 | 153 | if gem_env.user 154 | user_dir = Etc.getpwnam(gem_env.user).dir 155 | environment = { 'USER' => gem_env.user, 'HOME' => user_dir } 156 | else 157 | user_dir = nil 158 | environment = nil 159 | end 160 | 161 | shell_out!(rvm_wrap_cmd(cmd, user_dir), :env => environment) 162 | end 163 | 164 | def remove_package(name, version) 165 | uninstall_via_gem_command(name, version) 166 | end 167 | 168 | def uninstall_via_gem_command(name, version) 169 | cmd = %{rvm #{ruby_strings.join(',')} #{rvm_do(gem_env.user)} #{gem_binary_path}} 170 | cmd << %{ uninstall #{name} -q -x -I} 171 | if version 172 | cmd << %{ -v "#{version}"#{opts}} 173 | else 174 | cmd << %{ -a#{opts}} 175 | end 176 | 177 | if gem_env.user 178 | user_dir = Etc.getpwnam(gem_env.user).dir 179 | environment = { 'USER' => gem_env.user, 'HOME' => user_dir } 180 | else 181 | user_dir = nil 182 | environment = nil 183 | end 184 | 185 | shell_out!(rvm_wrap_cmd(cmd, user_dir), :env => environment) 186 | end 187 | end 188 | end 189 | end 190 | end 191 | -------------------------------------------------------------------------------- /libraries/chef_rvm_recipe_helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: rvm 3 | # Library:: Chef::RVM::RecipeHelpers 4 | # 5 | # Author:: Fletcher Nichol 6 | # 7 | # Copyright 2011, Fletcher Nichol 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | class Chef 23 | module RVM 24 | module RecipeHelpers 25 | def build_script_flags(branch, version = "head") 26 | if version =~ /\A\d+\.\d+\.\d+/ && %w{stable master none}.include?(branch) 27 | " -s -- --version #{version}" 28 | else 29 | " -s -- --branch #{branch} --version #{version}" 30 | end 31 | end 32 | 33 | def build_upgrade_strategy(strategy) 34 | if strategy.nil? || strategy == false 35 | "none" 36 | else 37 | strategy 38 | end 39 | end 40 | 41 | def install_pkg_prereqs(install_now = node.recipe?("rvm::gem_package")) 42 | return if mac_with_no_homebrew 43 | 44 | node['rvm']['install_pkgs'].each do |pkg| 45 | p = package pkg do 46 | # excute in compile phase if gem_package recipe is requested 47 | if install_now 48 | action :nothing 49 | else 50 | action :install 51 | end 52 | end 53 | p.run_action(:install) if install_now 54 | end 55 | end 56 | 57 | def install_rvm(opts = {}) 58 | install_now = node.recipe?("rvm::gem_package") 59 | 60 | if opts[:user] 61 | user_dir = opts[:rvm_prefix] 62 | exec_name = "install user RVM for #{opts[:user]}" 63 | exec_env = { 'USER' => opts[:user], 'HOME' => user_dir, 'TERM' => 'dumb' } 64 | else 65 | user_dir = nil 66 | exec_name = "install system-wide RVM" 67 | exec_env = { 'TERM' => 'dumb' } 68 | end 69 | 70 | rvm_installed_check = rvm_wrap_cmd( 71 | %{type rvm | cat | head -1 | grep -q '^rvm is a function$'}, user_dir 72 | ) 73 | install_command = "curl -L #{opts[:installer_url]} | bash #{opts[:script_flags]}" 74 | install_user = opts[:user] || "root" 75 | 76 | log "Performing RVM install with [#{install_command}] (as #{install_user})" 77 | 78 | i = execute exec_name do 79 | user install_user 80 | command install_command 81 | environment(exec_env) 82 | 83 | # excute in compile phase if gem_package recipe is requested 84 | if install_now 85 | action :nothing 86 | else 87 | action :run 88 | end 89 | 90 | not_if rvm_installed_check, :environment => exec_env 91 | end 92 | i.run_action(:run) if install_now 93 | end 94 | 95 | def upgrade_rvm(opts = {}) 96 | install_now = node.recipe?("rvm::gem_package") 97 | 98 | if opts[:user] 99 | user_dir = opts[:rvm_prefix] 100 | exec_name = "upgrade user RVM for #{opts[:user]} to " + 101 | opts[:upgrade_strategy] 102 | exec_env = { 'USER' => opts[:user], 'HOME' => user_dir } 103 | else 104 | user_dir = nil 105 | exec_name = "upgrade system-wide RVM to " + 106 | opts[:upgrade_strategy] 107 | exec_env = nil 108 | end 109 | 110 | upgrade_cmd = rvm_wrap_cmd( 111 | %{rvm get #{opts[:upgrade_strategy]}}, user_dir 112 | ) 113 | 114 | u = execute exec_name do 115 | user opts[:user] || "root" 116 | command upgrade_cmd 117 | environment(exec_env) 118 | 119 | # excute in compile phase if gem_package recipe is requested 120 | if install_now 121 | action :nothing 122 | else 123 | action :run 124 | end 125 | 126 | not_if { opts[:upgrade_strategy] == "none" } 127 | end 128 | u.run_action(:run) if install_now 129 | end 130 | 131 | def rvmrc_template(opts = {}) 132 | install_now = node.recipe?("rvm::gem_package") 133 | 134 | if opts[:user] 135 | system_install = false 136 | rvmrc_file = "#{opts[:rvm_prefix]}/.rvmrc" 137 | rvm_path = "#{opts[:rvm_prefix]}/.rvm" 138 | else 139 | system_install = true 140 | rvmrc_file = "/etc/rvmrc" 141 | rvm_path = "#{opts[:rvm_prefix]}/rvm" 142 | end 143 | 144 | t = template rvmrc_file do 145 | source "rvmrc.erb" 146 | owner opts[:user] || "root" 147 | mode "0644" 148 | variables :system_install => system_install, 149 | :rvm_path => rvm_path, 150 | :rvm_gem_options => opts[:rvm_gem_options], 151 | :rvmrc => opts[:rvmrc] 152 | 153 | # excute in compile phase if gem_package recipe is requested 154 | if install_now 155 | action :nothing 156 | else 157 | action :create 158 | end 159 | end 160 | t.run_action(:create) if install_now 161 | end 162 | 163 | def install_rubies(opts = {}) 164 | # install additional rubies 165 | opts[:rubies].each do |rubie| 166 | if rubie.is_a?(Hash) 167 | ruby = rubie.fetch("version") 168 | ruby_patch = rubie.fetch("patch", nil) 169 | ruby_rubygems_version = rubie.fetch("rubygems_version", nil) 170 | else 171 | ruby = rubie 172 | ruby_patch = nil 173 | ruby_rubygems_version = nil 174 | end 175 | 176 | rvm_ruby ruby do 177 | patch ruby_patch 178 | user opts[:user] 179 | rubygems_version ruby_rubygems_version 180 | end 181 | end 182 | 183 | # set a default ruby 184 | rvm_default_ruby opts[:default_ruby] do 185 | user opts[:user] 186 | end 187 | 188 | # install global gems 189 | opts[:global_gems].each do |gem| 190 | rvm_global_gem gem[:name] do 191 | user opts[:user] 192 | [:version, :action, :options, :source].each do |attr| 193 | send(attr, gem[attr]) if gem[attr] 194 | end 195 | end 196 | end 197 | 198 | # install additional gems 199 | opts[:gems].each_pair do |rstring, gems| 200 | rvm_environment rstring do 201 | user opts[:user] 202 | end 203 | 204 | gems.each do |gem| 205 | rvm_gem gem[:name] do 206 | ruby_string rstring 207 | user opts[:user] 208 | [:version, :action, :options, :source].each do |attr| 209 | send(attr, gem[attr]) if gem[attr] 210 | end 211 | end 212 | end 213 | end 214 | end 215 | 216 | private 217 | 218 | def mac_with_no_homebrew 219 | %w{ mac_os_x mac_os_x_server }.include?(node['platform']) && 220 | Chef::Platform.find_provider_for_node(node, :package) != 221 | Chef::Provider::Package::Homebrew 222 | end 223 | end 224 | end 225 | end 226 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.9.1 (unreleased) 2 | 3 | ### Bug fixes 4 | 5 | * Pull request [#137](https://github.com/fnichol/chef-rvm/pull/137): Fix patch attribute support in rvm\_ruby. ([@mariussturm][]) 6 | * Pull request [#140](https://github.com/fnichol/chef-rvm/pull/140): Update MRI package requirements for scientific-6 platforms. ([@aaronjensen][]) 7 | * Pull request [#134](https://github.com/fnichol/chef-rvm/pull/134): Fix vagrant\_ruby default location on modern vagrant baseboxes. ([@mveytsman][]) 8 | * Pull request [#129](https://github.com/fnichol/chef-rvm/pull/129): Fix broken example in README. ([@zacharydanger][]) 9 | * Pull request [#188](https://github.com/fnichol/chef-rvm/pull/188): Added missing dependencies. ([@fmfdias][]) 10 | * Pull request [#151](https://github.com/fnichol/chef-rvm/pull/151): Add Berkshelf installation instructions. ([@justincampbell][]) 11 | * Pull request [#128](https://github.com/fnichol/chef-rvm/pull/128): Allow for universal rvmrc settings to be used in the user\_install. ([@firebelly][]) 12 | 13 | ### New features 14 | 15 | * Pull request [#100](https://github.com/fnichol/chef-rvm/pull/100): Add rubygems\_version attribute to rvm\_ruby resource. ([@cgriego][]) 16 | * Pull request [#125](https://github.com/fnichol/chef-rvm/pull/125): Omnibus support (via chef\_gem). ([@gondoi][], [@cgriego][], [@jblatt-verticloud][], [@jschneiderhan][]) 17 | * Set name attribute in metadata.rb, which may help certain LWRP auto-naming issues when directory name does not match 'rvm' (FC045). ([@fnichol][]) 18 | 19 | ### Improvements 20 | 21 | * Refactor foodcritic setup. ([@fnichol][]) 22 | 23 | 24 | ## 0.9.0 (May 15, 2012) 25 | 26 | ### RVM API tracking updates 27 | 28 | * Drop rake 0.9.2 from default global gems to match upstream default. ([@fnichol][]) 29 | * Use RVM stable (stable/head) by default. ([@fnichol][]) 30 | * Pull request [#84](https://github.com/fnichol/chef-rvm/pull/84): Add stable support to installer. ([@xdissent][]) 31 | * Pull request [#102](https://github.com/fnichol/chef-rvm/pull/102): Switch URLs to rvm.io and add "rvm get stable". ([@mpapis][]) 32 | 33 | ### Bug fixes 34 | 35 | * Pull request [#64](https://github.com/fnichol/chef-rvm/pull/64): Fix check for rvm in user install. ([@dokipen][]) 36 | * Issue [#61](https://github.com/fnichol/chef-rvm/issues/61): Include Chef::RVM::StringHelpers to provide select_ruby function. ([@jheth][]) 37 | * Pull request [#94](https://github.com/fnichol/chef-rvm/pull/94): Prevent rvm from reinstalling each chef run. ([@xdissent][]) 38 | * Pull request [#66](https://github.com/fnichol/chef-rvm/pull/66): Fixing NoMethodError when using system wide rvm and the gem_package resource. ([@kristopher][]) 39 | * Pull request [#95](https://github.com/fnichol/chef-rvm/pull/95): Fix missing `patch` resource attributes. ([@xdissent][]) 40 | * Pull request [#96](https://github.com/fnichol/chef-rvm/pull/96): Fix wrapper paths, now works for both system and user installs. ([@xdissent][]) 41 | * LWRPs now notify when updated (FC017). ([@fnichol][]) 42 | * Node attribute access style (FC019). ([@fnichol][]) 43 | * FC023: Prefer conditional attributes. ([@fnichol][]) 44 | 45 | ### New features 46 | 47 | * Update default Ruby to ruby-1.9.3-p194 (it's time). ([@fnichol][]) 48 | * Pull request [#86](https://github.com/fnichol/chef-rvm/pull/76): Add patch attribute to rvm_ruby. ([@smdern][]) 49 | * Pull request [#76](https://github.com/fnichol/chef-rvm/pull/76): Add wrapper for chef-client. ([@bryanstearns][]) 50 | 51 | ### Improvements 52 | 53 | * Add TravisCI support for Foodcritic. ([@fnichol][]) 54 | * Large formatting updates to README. ([@fnichol][]) 55 | * Add gh-pages branch for sectioned README at https://fnichol.github.com/chef-rvm. ([@fnichol][]) 56 | * Issue [#98](https://github.com/fnichol/chef-rvm/issues/98): Support installs of x.y.z versions & more permissive upgrade options. ([@fnichol][]) 57 | * Now rvm\_global\_gem respects version attr in global.gems file. ([@fnichol][]) 58 | * Pull request [#88](https://github.com/fnichol/chef-rvm/pull/88): Mac OS X Server support. ([@rhenning][]) 59 | * Pull request [#90](https://github.com/fnichol/chef-rvm/pull/90): Scientific Linux support. ([@TrevorBramble][]) 60 | 61 | 62 | ## 0.8.6 (November 28, 2011) 63 | 64 | ### RVM API tracking updates 65 | 66 | * Issue [#56](https://github.com/fnichol/chef-rvm/issues/56): Ensure that RVM version strings can be converted to RubyGems format. ([@fnichol][]) 67 | * Issue [#53](https://github.com/fnichol/chef-rvm/issues/53): Update rvm/installer\_url default to latest URL. ([@fnichol][]) 68 | 69 | ### Bug fixes 70 | 71 | * Issue [#54](https://github.com/fnichol/chef-rvm/issues/54), Pull request [#55](https://github.com/fnichol/chef-rvm/pull/55): Fix if statement typo in `RVM::RubyGems::Package`. ([@bradphelan][]) 72 | * Pull request [#57](https://github.com/fnichol/chef-rvm/pull/57): Fix typo in `RVM::RubyGems::Package`. ([@bradphelan][]) 73 | 74 | ### Improvements 75 | 76 | * Add note to README warning that chef 0.8.x will not work. ([@fnichol][]) 77 | * Issue [#48](https://github.com/fnichol/chef-rvm/issues/48): Add example of local gem source installation in README. ([@fnichol][]) 78 | 79 | 80 | ## 0.8.4 (October 16, 2011) 81 | 82 | ### RVM API tracking updates 83 | 84 | * Issue [#43](https://github.com/fnichol/chef-rvm/issues/43), Pull request [#46](https://github.com/fnichol/chef-rvm/pull/46): Make explicit use of `exec` for RVM versions older than 1.8.6 and `do` for newer versions. ([@ryansch][], [@fnichol][]) 85 | 86 | ### Bug fixes 87 | 88 | * Pull request [#39](https://github.com/fnichol/chef-rvm/pull/39): Fix rvm_ruby provider on Ubuntu/Debian when installing JRuby. ([@exempla][]) 89 | * Issues [#38](https://github.com/fnichol/chef-rvm/issues/38), [#42](https://github.com/fnichol/chef-rvm/issues/42): Update user_installs attribute to be an array of hashes in README. ([@fnichol][]) 90 | 91 | ### New features 92 | 93 | * Pull request [#47](https://github.com/fnichol/chef-rvm/pull/47): Handle installing a gem from a local file. ([@ryansch][]) 94 | 95 | ### Improvements 96 | 97 | * Pull request [#44](https://github.com/fnichol/chef-rvm/pull/44): Add Amazon's Linux AMI support. ([@adrianpike][]) 98 | 99 | 100 | ## 0.8.2 (August 24, 2011) 101 | 102 | ### Bug fixes 103 | 104 | * Ensure Ruby/gemset is installed in rvm_shell provider. ([@fnichol][]) 105 | * Issue [#35](https://github.com/fnichol/chef-rvm/issues/35): Detect if user has RVM installed in rvm_shell provider. ([@fnichol][]) 106 | 107 | ### Improvements 108 | 109 | * Array-ize node['rvm']['user_installs']. ([@fnichol][]) 110 | 111 | 112 | ## 0.8.0 (August 22, 2011) 113 | 114 | ### Bug fixes 115 | 116 | * Pull request [#22](https://github.com/fnichol/chef-rvm/pull/22): Expand list of sane rubies to include `"ree"` and `"kiji"`. ([@juzzin][]) 117 | * Pull request [#26](https://github.com/fnichol/chef-rvm/pull/26): RVM is installed in compilation phase when gem_package recipe is included. ([@temujin9][], [@fnichol][]) 118 | * Update rvm/vagrant/system_chef_solo default attribute value to match newest Vagrant lucid32 basebox. ([@fnichol][]) 119 | * Pull request [#27](https://github.com/fnichol/chef-rvm/pull/27): Explicitly handle the unmanaged 'system' ruby. ([@temujin9][]). 120 | * Pull request [#28](https://github.com/fnichol/chef-rvm/pull/28): Fix bug when no RVM rubies had yet been installed. ([@relistan][]). 121 | * Pull request [#30](https://github.com/fnichol/chef-rvm/pull/30): Implement 'group_users' support. ([@phlipper][]). 122 | * Update ruby compilation dependencies for debian/ubuntu. ([@fnichol][]) 123 | 124 | ### New features 125 | 126 | * Issue [#4](https://github.com/fnichol/chef-rvm/issues/4): Per-user RVM installs with support in all LWRPs. ([@fnichol][]) 127 | * Refactor system and user installs into: system_install, system, user_install, user ([reference](https://github.com/fnichol/chef-rvm/commit/69027cafbe8e25251a797f1dcf11e5bc4c96275b)). ([@fnichol][]) 128 | * Support Mac OS X platform for system-wide and per-user installs. ([@fnichol][]) 129 | * Issue [#23](https://github.com/fnichol/chef-rvm/issues/24): Let gem_package resource target multiple RVM rubies. ([@fnichol][]) 130 | * Pull request [#26](https://github.com/fnichol/chef-rvm/pull/26): Add new attribute `group_id`. ([@temujin9][]) 131 | * General refactoring and re-modularizing. ([@fnichol][]) 132 | 133 | ### Improvements 134 | 135 | * Pull request [#26](https://github.com/fnichol/chef-rvm/pull/26): RVM unix group is created in compilation phase if GID is provided. ([@temujin9][]) 136 | * Revamp CHANGELOG in the style of [guard](https://github.com/guard/guard). ([@fnichol][]) 137 | * Pull request [#27](https://github.com/fnichol/chef-rvm/pull/27): Improve gem_package logging message to include full list of selected rubies. ([@temujin9][]) 138 | * RVM gem installed using opscode cookbook conventions (via gem_package). ([@fnichol][]) 139 | * Add RVM::Shell::ChefWrapper based on chef's popen4 impl. ([@fnichol][]) 140 | * Create RVM::ChefUserEnvironment which can be injected with a user. ([@fnichol][]) 141 | * Normalize 'missing gem' logging notices. ([@fnichol][]) 142 | * Add Chef::RVM::StringCache to get and cache canonical RVM strings. ([@fnichol][]) 143 | * Modularize `libraries/helpers.rb` in modules. ([@fnichol][]) 144 | * Issue [#25](https://github.com/fnichol/chef-rvm/issues/25): Add installation options/instructions to README. ([@fnichol][]) 145 | 146 | 147 | ## 0.7.1 (May 15, 2011) 148 | 149 | ### Bug fixes 150 | 151 | * Issue [#20](https://github.com/fnichol/chef-rvm/issues/20): Update metadata.rb to not include README.md (too long). ([@fnichol][]) 152 | 153 | ### New features 154 | 155 | * Add Rakefile for opscode platform deploy builds. ([@fnichol][]) 156 | 157 | ### Improvements 158 | 159 | * Update metadata.rb properties. ([@fnichol][]) 160 | 161 | 162 | ## 0.7.0 (May 14, 2011) 163 | 164 | ### Bug fixes 165 | 166 | * Issue [#20](https://github.com/fnichol/chef-rvm/issues/20): Update rvm/install_rubies attr to "true"/"false". ([@fnichol][]) 167 | * Issue [#14](https://github.com/fnichol/chef-rvm/issues/14): Allow no default RVM ruby (i.e. use system ruby). ([@fnichol][]) 168 | * Issue [#12](https://github.com/fnichol/chef-rvm/issues/12): Update RVM install to use SSL URL. ([@fnichol][]) 169 | * Now /etc/rvmrc has export for rvm/rvmrc key/value pairs. ([@fnichol][]) 170 | 171 | ### New features 172 | 173 | * Issue [#13](https://github.com/fnichol/chef-rvm/issues/13): Speed up install by disabling RDOC generation. ([@fnichol][]) 174 | * New experimental recipe gem_package which patches gem_package resource. ([@fnichol][]) 175 | * Add rvm_global_gem resource. ([@fnichol][]) 176 | 177 | ### Improvements 178 | 179 | * Issue [#3](https://github.com/fnichol/chef-rvm/issues/3): Revamp and update README.md. ([@fnichol][]) 180 | * Issue [#3](https://github.com/fnichol/chef-rvm/issues/5): Add CHANGELOG.md. ([@fnichol][]) 181 | * Issue [#19](https://github.com/fnichol/chef-rvm/issues/19): Attr rvm/upgrade accepts "none", false and nil as same value. ([@fnichol][]) 182 | * Update rvm/skip_docs_on_install attr to rvm/rvm_gem_options. ([@fnichol][]) 183 | * Refactor of rvm_gem provider to leverage Chef::Provider::Package::Rubygems. ([@fnichol][]) 184 | 185 | 186 | ## Previous releases 187 | 188 | The changelog began with version 0.6.0 so any changes prior to that can be 189 | seen by checking the tagged releases and reading git commit messages. 190 | 191 | [@aaronjensen]: https://github.com/aaronjensen 192 | [@adrianpike]: https://github.com/adrianpike 193 | [@bradphelan]: https://github.com/bradphelan 194 | [@bryanstearns]: https://github.com/bryanstearns 195 | [@cgriego]: https://github.com/cgriego 196 | [@dokipen]: https://github.com/dokipen 197 | [@exempla]: https://github.com/exempla 198 | [@fnichol]: https://github.com/fnichol 199 | [@gondoi]: https://github.com/gondoi 200 | [@jblatt-verticloud]: https://github.com/jblatt-verticloud 201 | [@jheth]: https://github.com/jheth 202 | [@jschneiderhan]: https://github.com/jschneiderhan 203 | [@juzzin]: https://github.com/juzzin 204 | [@kristopher]: https://github.com/kristopher 205 | [@mariussturm]: https://github.com/mariussturm 206 | [@mpapis]: https://github.com/mpapis 207 | [@mveytsman]: https://github.com/mveytsman 208 | [@phlipper]: https://github.com/phlipper 209 | [@relistan]: https://github.com/relistan 210 | [@rhenning]: https://github.com/rhenning 211 | [@ryansch]: https://github.com/ryansch 212 | [@smdern]: https://github.com/smdern 213 | [@temujin9]: https://github.com/temujin9 214 | [@TrevorBramble]: https://github.com/TrevorBramble 215 | [@xdissent]: https://github.com/xdissent 216 | [@zacharydanger]: https://github.com/zacharydanger 217 | [@fmfdias]: https://github.com/fmfdias 218 | [@justincampbell]: https://github.com/justincampbell 219 | [@firebelly]: https://github.com/firebelly 220 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chef-rvm [![Build Status](https://secure.travis-ci.org/fnichol/chef-rvm.png?branch=master)](http://travis-ci.org/fnichol/chef-rvm) 2 | 3 | ## Description 4 | 5 | Manages system-wide and per-user [RVM][rvm]s and manages installed Rubies. 6 | Several lightweight resources and providers ([LWRP][lwrp]) are also defined. 7 | 8 | ## Usage 9 | 10 | ### RVM Installed System-Wide with Rubies 11 | 12 | Most likely, this is the typical case. Include `recipe[rvm::system]` in your 13 | run_list and override the defaults you want changed. See below for more 14 | details. 15 | 16 | ### RVM Installed For A Specific User with Rubies 17 | 18 | If you want a per-user install (like on a Mac/Linux workstation for 19 | development), include `recipe[rvm::user]` in your run_list and add a user 20 | hash to the `user_installs` attribute list. For example: 21 | 22 | node['rvm']['user_installs'] = [ 23 | { 'user' => 'wigglebottom', 24 | 'default_ruby' => 'rbx', 25 | 'rubies' => ['1.9.2', '1.8.7'] 26 | } 27 | ] 28 | 29 | See below for more details. 30 | 31 | ### RVM Installed System-Wide and LWRPs Defined 32 | 33 | If you want to manage your own RVM environment with the provided [LWRP][lwrp]s, 34 | then include `recipe[rvm::system_install]` in your run_list to prevent 35 | a default RVM Ruby being installed. See the **Resources and Providers** 36 | section for more details. 37 | 38 | ### RVM Installed For A Specific User and LWRPs Defined 39 | 40 | If you want to manage your own RVM environment for users with the provided 41 | LWRPs, then include `recipe[rvm::user_install]` in your run_list and add a 42 | user hash to the `user_installs` attribute list. For example: 43 | 44 | node['rvm']['user_installs'] = [ 45 | { 'user' => 'wigglebottom' } 46 | ] 47 | 48 | See the **Resources and Providers** section for more details. 49 | 50 | ### Ultra-Minimal Access To LWRPs 51 | 52 | Simply include `recipe[rvm]` in your run_list and the LWRPs will be available 53 | to use in other cookbooks. See the **Resources and Providers** section for 54 | more details. 55 | 56 | ### Other Use Cases 57 | 58 | * If node is running in a Vagrant VM, then including `recipe[rvm::vagrant]` 59 | in your run_list can help with resolving the *chef-solo* binary on subsequent 60 | provision executions. 61 | * If you want other Chef cookbooks to install RubyGems in RVM-managed Rubies, 62 | you can try including `recipe[rvm::gem_package]` in your run_list. Please 63 | read the recipe details before attempting. 64 | 65 | ## Requirements 66 | 67 | ### Chef 68 | 69 | Tested on 0.10.2/0.10.4 and 0.9.16 but newer and older versions (of 0.9.x) 70 | should work just fine. Due to the `rvm_gem` implementation, versions 0.8.x 71 | of Chef currently will **not** work (see [GH-50][gh50]). 72 | 73 | File an [issue][issues] if this isn't the case. 74 | 75 | ### Platform 76 | 77 | The following platforms have been tested with this cookbook, meaning that 78 | the recipes and LWRPs run on these platforms without error: 79 | 80 | * ubuntu (10.04/10.10/11.04/12.04) 81 | * debian (6.0) 82 | * mac_os_x (10.6/10.7) 83 | * mac_os_x_server 84 | * suse (openSUSE, SLES) 85 | * centos 86 | * amazon (2011.09) 87 | * scientific 88 | * redhat 89 | * fedora 90 | 91 | Please [report][issues] any additional platforms so they can be added. 92 | 93 | ### Cookbooks 94 | 95 | This cookbook depends on the following external cookbooks: 96 | 97 | * [chef\_gem][chef_gem_cb] 98 | 99 | If you are installing [JRuby][jruby] then a Java runtime will need to be 100 | installed. The Opscode [java cookbook][java_cb] can be used on supported 101 | platforms. 102 | 103 | ## Installation 104 | 105 | Depending on the situation and use case there are several ways to install 106 | this cookbook. All the methods listed below assume a tagged version release 107 | is the target, but omit the tags to get the head of development. A valid 108 | Chef repository structure like the [Opscode repo][chef_repo] is also assumed. 109 | 110 | ### Using Berkshelf 111 | 112 | [Berkshelf][berkshelf] is a way to manage a cookbook or an application's 113 | cookbook dependencies. Include the cookbook in your Berksfile, and then run 114 | `berks install`. To install using Berkshelf: 115 | 116 | gem install berkshelf 117 | cd chef-repo 118 | berks init 119 | echo "cookbook 'rvm', github: 'fnichol/chef-rvm'" >> Berksfile 120 | berks install 121 | 122 | ### Using Librarian-Chef 123 | 124 | [Librarian-Chef][librarian] is a bundler for your Chef cookbooks. 125 | Include a reference to the cookbook in a [Cheffile][cheffile] and run 126 | `librarian-chef install`. To install Librarian-Chef: 127 | 128 | gem install librarian 129 | cd chef-repo 130 | librarian-chef init 131 | cat >> Cheffile < 'git://github.com/fnichol/chef-rvm.git', :ref => 'v0.9.0' 134 | END_OF_CHEFFILE 135 | librarian-chef install 136 | 137 | ### Using knife-github-cookbooks 138 | 139 | The [knife-github-cookbooks][kgc] gem is a plugin for *knife* that supports 140 | installing cookbooks directly from a GitHub repository. To install with the 141 | plugin: 142 | 143 | gem install knife-github-cookbooks 144 | cd chef-repo 145 | knife cookbook github install fnichol/chef-rvm/v0.9.0 146 | 147 | ### As a Git Submodule 148 | 149 | A common practice (which is getting dated) is to add cookbooks as Git 150 | submodules. This is accomplishes like so: 151 | 152 | cd chef-repo 153 | git submodule add git://github.com/fnichol/chef-rvm.git cookbooks/rvm 154 | git submodule init && git submodule update 155 | 156 | **Note:** the head of development will be linked here, not a tagged release. 157 | 158 | ### As a Tarball 159 | 160 | If the cookbook needs to downloaded temporarily just to be uploaded to a Chef 161 | Server or Opscode Hosted Chef, then a tarball installation might fit the bill: 162 | 163 | cd chef-repo/cookbooks 164 | curl -Ls https://github.com/fnichol/chef-rvm/tarball/v0.9.0 | tar xfz - && \ 165 | mv fnichol-chef-rvm-* rvm 166 | 167 | ### From the Opscode Community Platform 168 | 169 | This cookbook is not currently available on the site due to the flat 170 | namespace for cookbooks. There is some community work to be done here. 171 | 172 | ## Recipes 173 | 174 | ### default 175 | 176 | Installs the RVM gem and initializes Chef to use the Lightweight Resources 177 | and Providers ([LWRPs][lwrp]). 178 | 179 | Use this recipe explicitly if you only want access to the LWRPs provided. 180 | 181 | ### system_install 182 | 183 | Installs the RVM codebase system-wide (that is, into `/usr/local/rvm`). This 184 | recipe includes *default*. 185 | 186 | Use this recipe by itself if you want RVM installed system-wide but want 187 | to handle installing Rubies, invoking LWRPs, etc.. 188 | 189 | ### system 190 | 191 | Installs the RVM codebase system-wide (that is, into `/usr/local/rvm`) and 192 | installs Rubies, global gems, and specific gems driven off attribute metadata. 193 | This recipe includes *default* and *system_install*. 194 | 195 | Use this recipe by itself if you want RVM system-wide with Rubies installed, 196 | etc. 197 | 198 | ### user_install 199 | 200 | Installs the RVM codebase for a list of users (selected from the 201 | `node['rvm']['user_installs']` hash). This recipe includes *default*. 202 | 203 | Use this recipe by itself if you want RVM installed for specific users in 204 | isolation but want each user to handle installing Rubies, invoking LWRPs, etc. 205 | 206 | ### user 207 | 208 | Installs the RVM codebase for a list of users (selected from the 209 | `node['rvm']['user_installs']` hash) and installs Rubies, global gems, and 210 | specific gems driven off attribute metadata. This recipe includes *default* 211 | and *user_install*. 212 | 213 | Use this recipe by itself if you want RVM installed for specific users in 214 | isolation with Rubies installed, etc. 215 | 216 | ### vagrant 217 | 218 | An optional recipe if Chef is installed in a non-RVM Ruby in a 219 | [Vagrant][vagrant] virtual machine. This recipe adds the default *vagrant* 220 | user to the RVM unix group and installs a `chef-solo` wrapper script so Chef 221 | doesn't need to be re-installed in the default RVM Ruby. 222 | 223 | ### gem_package 224 | 225 | An experimental recipe that patches the [gem_package resource][gem_package] 226 | to use the `Chef::Provider::Package::RVMRubygems` provider. An attribute 227 | `rvm/gem_package/rvm_string` will determine which RVM Ruby is used for 228 | install/remove/upgrade/purge actions. This may help when using a third 229 | party or upstream cookbook that assumes a non-RVM managed system Ruby. 230 | 231 | **Note:** When this recipe is included it will force RVM to be 232 | installed in the [compilation phase][compilation]. This will ensure that all 233 | Rubies can be available if any `gem_package` resource calls are issued from 234 | other cookbooks during the compilation phase. 235 | 236 | **Warning:** [Here be dragons][dragons]! This is either brilliant or the 237 | dumbest idea ever, so feedback is appreciated. 238 | 239 | ## Attributes 240 | 241 | ### default_ruby 242 | 243 | The default Ruby for RVM installed system-wide. If the RVM Ruby is not 244 | installed, it will be built as a pre-requisite. The value can also contain a 245 | gemset in the form of `"ruby-1.8.7-p352@awesome"`. 246 | 247 | The default is `"ruby-2.0.0-p0"`. To disable a default Ruby from being 248 | set, use an empty string (`""`) or a value of `"system"`. 249 | 250 | ### user_default_ruby 251 | 252 | The default Ruby for RVMs installed per-user when not explicitly set for that 253 | user. If the RVM Ruby is not installed, it will be built as a pre-requisite. 254 | The value can also contain a gemset in the form of `"ruby-1.8.7-p352@awesome"`. 255 | 256 | The default is `"ruby-2.0.0-p0"`. To disable a default Ruby from being 257 | set, use an empty string (`""`) or a value of `"system"`. 258 | 259 | ### rubies 260 | 261 | A list of additional RVM system-wide Rubies to be built and installed. This 262 | list does not need to necessarily contain your default Ruby as the 263 | `rvm_default_ruby` resource will take care of installing itself. You may also 264 | include patch info and a rubygems version. For example: 265 | 266 | node['rvm']['rubies'] = [ 267 | "ree-1.8.7", 268 | "jruby", 269 | { 270 | 'version' => '1.9.3-p125-perf', 271 | 'patch' => 'falcon', 272 | 'rubygems_version' => '1.5.2' 273 | } 274 | ] 275 | 276 | The default is an empty array: `[]`. 277 | 278 | ### user_rubies 279 | 280 | A list of additional RVM Rubies to be built and installed per-user when not 281 | explicitly set. This list does not need to necessarily contain your default 282 | Ruby as the `rvm_default_ruby` resource will take care of installing itself. 283 | For example: 284 | 285 | node['rvm']['user_rubies'] = [ "ree-1.8.7", "jruby" ] 286 | 287 | The default is an empty array: `[]`. 288 | 289 | ### global_gems 290 | 291 | A list of gem hashes to be installed into the *global* gemset in each 292 | installed RVM Ruby sytem-wide. The **global.gems** files will be added to and 293 | all installed Rubies will be iterated over to ensure full installation 294 | coverage. See the `rvm_gem` resource for more details about the options for 295 | each gem hash. 296 | 297 | The default puts bundler and rake in each Ruby: 298 | 299 | node['rvm']['global_gems'] = [ 300 | { 'name' => 'bundler' }, 301 | { 'name' => 'rake', 302 | 'version' => '0.9.2' 303 | }, 304 | { 'name' => 'rubygems-bundler', 305 | 'action' => 'remove' 306 | } 307 | ] 308 | 309 | ### user_global_gems 310 | 311 | A list of gem hashes to be installed into the *global* gemset in each 312 | installed RVM Ruby for each user when not explicitly set. The 313 | **global.gems** files will be added to and all installed Rubies will be 314 | iterated over to ensure full installation coverage. See the `rvm_gem` 315 | resource for more details about the options for each gem hash. 316 | 317 | The default puts bundler and rake in each Ruby: 318 | 319 | node['rvm']['user_global_gems'] = [ 320 | { 'name' => 'bundler' }, 321 | { 'name' => 'rake', 322 | 'version' => '0.9.2' 323 | }, 324 | { 'name' => 'rubygems-bundler', 325 | 'action' => 'remove' 326 | } 327 | ] 328 | 329 | ### gems 330 | 331 | A list of gem hashes to be installed into arbitrary RVM Rubies and gemsets 332 | system-wide. See the `rvm_gem` resource for more details about the options for 333 | each gem hash and target Ruby environment. For example: 334 | 335 | node['rvm']['gems'] = { 336 | 'ruby-1.9.2-p280' => [ 337 | { 'name' => 'vagrant' }, 338 | { 'name' => 'veewee' }, 339 | { 'name' => 'rake', 340 | 'version' => '0.9.2' 341 | } 342 | ], 343 | 'ruby-1.9.2-p280@empty-gemset' => [], 344 | 'jruby' => [ 345 | { 'name' => 'nokogiri', 346 | 'version' => '1.5.0.beta.2' 347 | }, 348 | { 'name' => 'warbler' } 349 | ] 350 | } 351 | 352 | The default is an empty hash: `{}`. 353 | 354 | ### user_gems 355 | 356 | A list of gem hashes to be installed into arbitrary RVM Rubies and gemsets 357 | for each user when not explicitly set. See the `rvm_gem` resource for more 358 | details about the options for each gem hash and target Ruby environment. See 359 | the `gems` attribute for an example. 360 | 361 | The default is an empty hash: `{}`. 362 | 363 | ### rvmrc 364 | 365 | A hash of system-wide `rvmrc` options. The key is the RVM setting name 366 | (in String or Symbol form) and the value is the desired setting value. 367 | An example used on a build box might be: 368 | 369 | node['rvm']['rvmrc'] = { 370 | 'rvm_project_rvmrc' => 1, 371 | 'rvm_gemset_create_on_use_flag' => 1, 372 | 'rvm_trust_rvmrcs_flag' => 1 373 | } 374 | 375 | The default is an empty hash: `{}`. 376 | 377 | ### user_installs 378 | 379 | A list of user specific RVM installation hashes. The `user_install` and 380 | `user` recipes use this attribute to determine per-user installation settings. 381 | The hash keys correspond to the default/system equivalents. For example: 382 | 383 | node['rvm']['user_installs'] = [ 384 | { 'user' => 'jdoe', 385 | 'upgrade' => "head", 386 | 'default_ruby' => 'ree', 387 | 'rvm_gem_options' => "", 388 | 'global_gems' => [ 389 | { 'name' => 'bundler', 390 | 'version' => '1.1.pre.7' 391 | }, 392 | { 'name' => 'rake' }, 393 | { 'name' => 'rubygems-bundler', 394 | 'action' => 'remove' 395 | } 396 | ] 397 | }, 398 | { 'user' => 'jenkins', 399 | 'version' => '1.7.0', 400 | 'default_ruby' => 'jruby-1.6.3', 401 | 'rubies' => [ 402 | "ree-1.8.7", 403 | "jruby", 404 | { 405 | 'version' => '1.9.3-p125-perf', 406 | 'patch' => "falcon", 407 | 'rubygems_version' => '1.5.2' 408 | } 409 | ], 410 | 'rvmrc' => { 411 | 'rvm_project_rvmrc' => 1, 412 | 'rvm_gemset_create_on_use_flag' => 1, 413 | 'rvm_pretty_print_flag' => 1 414 | }, 415 | 'global_gems' => [ 416 | { 'name' => 'bundler', 417 | 'version' => '1.1.pre.7' 418 | }, 419 | { 'name' => 'rake', 420 | 'version' => '0.8.7' 421 | }, 422 | { 'name' => 'rubygems-bundler', 423 | 'action' => 'remove' 424 | } 425 | ] 426 | } 427 | ] 428 | 429 | The default is an empty list: `[]`. 430 | 431 | ### installer_url 432 | 433 | The URL that provides the RVM installer. 434 | 435 | The default is `"https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer"`. 436 | 437 | ### branch 438 | 439 | A specific git branch to use when installing system-wide. For example: 440 | 441 | node['rvm']['branch'] = "crazy" 442 | 443 | The default is `"stable"` which corresponds to the stable release branch. 444 | 445 | ### version 446 | 447 | A specific tagged version or head of a branch to use when installing 448 | system-wide. This value is passed directly to the `rvm-installer` script and 449 | current valid values are: 450 | 451 | * `"head"` - the default, last git commit on a branch 452 | * a specific tagged version of the form `"1.2.3"`. 453 | 454 | You may want to use a specific version of RVM to prevent differences in 455 | deployment from one day to the next (RVM head moves pretty darn quickly). 456 | 457 | **Note** that if a version number is used, then `"none"` should be the value 458 | of the `branch` attribute. For example: 459 | 460 | node['rvm']['version'] = "1.13.4" 461 | node['rvm']['branch'] = "none" 462 | 463 | The default is `"head"`. 464 | 465 | ### upgrade 466 | 467 | Determines how to handle installing updates to the RVM framework system-wide. 468 | The value of this string is passed to `rvm get`. The possible values include: 469 | 470 | * `"none"`, `false`, or `nil`: will not update RVM and leave it in its 471 | current state. 472 | * Any other value is passed to `rvm get` as described on the 473 | [upgrading][rvm_upgrading] page. For example: `"latest"`, `"stable"`, 474 | and `"branch mpapis/shoes"`. 475 | 476 | The default is `"none"`. 477 | 478 | ### root_path 479 | 480 | The path prefix to RVM in a system-wide installation. 481 | 482 | The default is `"/usr/local/rvm"`. 483 | 484 | ### group_id 485 | 486 | The Unix *GID* to be used for the `rvm` group. If this attribute is set, 487 | the group will be created in the compilation phase to avoid any collisions 488 | with expected *GID*s in other cookbooks. If left at the default value, 489 | the RVM installer will create this group as normal. 490 | 491 | The default is `default`. 492 | 493 | ### group_users 494 | 495 | A list of users that will be added to the `rvm` group. These users 496 | will then be able to manage RVM in a system-wide installation. 497 | 498 | The default is an empty list: `[]`. 499 | 500 | ### rvm_gem_options 501 | 502 | These options are passed to the *gem* command in an RVM environment. 503 | In the interest of speed, rdoc and ri docs will not be generated by default. 504 | To re-enable the documentation generation set: 505 | 506 | node['rvm']['rvm_gem_options'] = "--rdoc --ri" 507 | 508 | The default is `"--no-rdoc --no-ri"`. 509 | 510 | ### install_rubies (Future Deprecation) 511 | 512 | Can enable or disable installation of a default Ruby and additional Rubies 513 | system-wide. For example: 514 | 515 | node['rvm']['install_rubies'] = "false" 516 | 517 | The default is `"true"`. 518 | 519 | **Note:** This remains a legacy setting and will be deprecated in 520 | the next minor version release. 521 | 522 | ### iuser_install_rubies (Future Deprecation) 523 | 524 | Can enable or disable installation of a default Ruby and additional Rubies 525 | per user. For example: 526 | 527 | node['rvm']['user_install_rubies'] = "false" 528 | 529 | The default is `"true"`. 530 | 531 | **Note:** This remains a legacy setting and will be deprecated in 532 | the next minor version release. 533 | 534 | ### gem_package/rvm_string 535 | 536 | If using the `gem_package` recipe, this determines which Ruby or Rubies will 537 | be used by the `gem_package` resource in other cookbooks. The value can be 538 | either a *String* (for example `ruby-1.8.7-p334`) or an *Array* of RVM Ruby 539 | strings (for example `['ruby-1.8.7-p334', 'system']`). To target an underlying 540 | unmanaged system Ruby you can use `system`. 541 | 542 | The default is the value of the `default_ruby` attribute. 543 | 544 | ### vagrant/system_chef_solo 545 | 546 | If using the `vagrant` recipe, this sets the path to the package-installed 547 | *chef-solo* binary. 548 | 549 | The default is `"/opt/ruby/bin/chef-solo"`. 550 | 551 | ## Resources and Providers 552 | 553 | ### rvm_ruby 554 | 555 | #### Actions 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 572 | 573 | 574 | 575 | 576 | 580 | 581 | 582 | 583 | 584 | 587 | 588 | 589 | 590 |
ActionDescriptionDefault
install 569 | Build and install an RVM Ruby. See RVM rubies/installing(1) 570 | for more details. 571 | Yes
remove 577 | Remove the Ruby, source files and optional gemsets/archives. See RVM 578 | rubies/removing(2) for more details. 579 |  
uninstall 585 | Just remove the Ruby and leave everything else. See RVM rubies/removing(3) for more details. 586 |  
591 | 592 | 1. [RVM rubies/installing][rvm_install] 593 | 2. [RVM rubies/removing][rvm_remove] 594 | 3. [RVM rubies/removing][rvm_remove] 595 | 596 | #### Attributes 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 614 | 615 | 616 | 617 | 618 | 624 | 625 | 626 | 627 |
AttributeDescriptionDefault Value
ruby_string 610 | Name attribute: an RVM Ruby string that could contain a gemset. 611 | If a gemset is given (for example, 612 | "ruby-1.8.7-p330@awesome"), then it will be stripped. 613 | nil
user 619 | A users's isolated RVM installation on which to apply an action. The 620 | default value of nil denotes a system-wide RVM 621 | installation is being targeted. Note: if specified, the user 622 | must already exist. 623 | nil
628 | 629 | #### Examples 630 | 631 | ##### Install Ruby 632 | 633 | rvm_ruby "ree" do 634 | action :install 635 | end 636 | 637 | rvm_ruby "jruby-1.6.3" 638 | 639 | **Note:** the install action is default, so the second example is a more common 640 | usage. 641 | 642 | ##### Remove Ruby 643 | 644 | rvm_ruby "ree-1.8.7-2011.01" do 645 | action :remove 646 | end 647 | 648 | **Note:** the RVM documentation mentions that this method is far preferred to 649 | using uninstall since it purges almost everything. 650 | 651 | ##### Uninstall Ruby 652 | 653 | rvm_ruby "ree-1.8.7-2011.01" do 654 | action :uninstall 655 | user "jenkins" 656 | end 657 | 658 | **Note:** The RVM installation for the *jenkins* user will be acted upon. 659 | 660 | ### rvm_default_ruby 661 | 662 | This resource sets the default RVM Ruby, optionally with gemset. The given 663 | Ruby will be installed if it isn't already and a gemset will be created in 664 | none currently exist. If multiple declarations are used then the last executed 665 | one "wins". 666 | 667 | #### Actions 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 684 | 685 | 686 | 687 |
ActionDescriptionDefault
create 681 | Set the default RVM Ruby. See RVM rubies/default(1) for 682 | more details. 683 | Yes
688 | 689 | 1. [RVM rubies/default][rvm_default] 690 | 691 | #### Attributes 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 709 | 710 | 711 | 712 | 713 | 719 | 720 | 721 | 722 |
AttributeDescriptionDefault Value
ruby_string 705 | Name attribute: an RVM Ruby string that could contain a gemset. 706 | If a gemset is given (for example, 707 | "ruby-1.8.7-p330@awesome"), then it will be included. 708 | nil
user 714 | A users's isolated RVM installation on which to apply an action. The 715 | default value of nil denotes a system-wide RVM 716 | installation is being targeted. Note: if specified, the 717 | user must already exist. 718 | nil
723 | 724 | #### Examples 725 | 726 | ##### Setting The Default Ruby 727 | 728 | rvm_default_ruby "ree" do 729 | action :create 730 | end 731 | 732 | rvm_default_ruby "jruby-1.5.6" 733 | 734 | **Note:** the create action is default, so the second example is a more common 735 | usage. 736 | 737 | ### rvm_environment 738 | 739 | This resource ensures that the specified RVM Ruby is installed and the optional 740 | gemset is created. It is a convenience resource which wraps `rvm_ruby` and 741 | `rvm_gemset` so it can be used as a sort of *über Ruby* resource which 742 | parallels the `rvm_default_ruby` resource. 743 | 744 | #### Actions 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 |
ActionDescriptionDefault
createInstalls the specified RVM Ruby and gemset.Yes
762 | 763 | #### Attributes 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 781 | 782 | 783 | 784 | 785 | 791 | 792 | 793 | 794 |
AttributeDescriptionDefault Value
ruby_string 777 | Name attribute: an RVM Ruby string that could contain a gemset. 778 | If a gemset is given (for example, 779 | "ruby-1.8.7-p330@awesome"), then it will be used. 780 | nil
user 786 | A users's isolated RVM installation on which to apply an action. The 787 | default value of nil denotes a system-wide RVM 788 | installation is being targeted. Note: if specified, the 789 | user must already exist. 790 | nil
795 | 796 | #### Examples 797 | 798 | ##### Creating A Passenger Environment In Production 799 | 800 | rvm_environment "ree-1.8.7-2011.01@passenger" 801 | 802 | ### rvm_gemset 803 | 804 | See [RVM gemsets][rvm_gemsets] for more background concerning gemsets. 805 | 806 | #### Actions 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 823 | 824 | 825 | 826 | 827 | 830 | 831 | 832 | 833 | 834 | 838 | 839 | 840 | 841 | 842 | 846 | 847 | 848 | 849 |
ActionDescriptionDefault
create 820 | Creates a new gemset in a given RVM Ruby. See RVM 821 | gemsets/creating(1) for more details. 822 | Yes
update 828 | Update all gems installed to the gemset in a given RVM Ruby. 829 |  
empty 835 | Remove all gems installed to the gemset in a given RVM Ruby. See RVM 836 | gemsets/emptying(2) for more details. 837 |  
delete 843 | Delete gemset from the given RVM Ruby. See RVM 844 | gemsets/deleting(3) for more details. 845 |  
850 | 851 | 1. [RVM gemsets/creating][rvm_create_gemset] 852 | 2. [RVM gemsets/emptying][rvm_empty_gemset] 853 | 3. [RVM gemsets/deleting][rvm_delete_gemset] 854 | 855 | #### Attributes 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 874 | 875 | 876 | 877 | 878 | 881 | 882 | 883 | 884 | 885 | 891 | 892 | 893 | 894 |
AttributeDescriptionDefault Value
gemset 869 | Name attribute: Either an RVM Ruby string containing a gemset 870 | or a bare gemset name. If only the gemset name is given, then the 871 | ruby_string attribute must be used to indicate which 872 | RVM Ruby to target. 873 | nil
ruby_string 879 | An RVM Ruby string that should not contain a gemset. 880 | nil
user 886 | A users's isolated RVM installation on which to apply an action. The 887 | default value of nil denotes a system-wide RVM 888 | installation is being targeted. Note: if specified, the 889 | user must already exist. 890 | nil
895 | 896 | #### Examples 897 | 898 | ##### Creating A Gemset 899 | 900 | rvm_gemset "rails" do 901 | ruby_string "ruby-1.9.2-p136" 902 | action :create 903 | end 904 | 905 | rvm_gemset "ruby-1.9.2-p136@rails" 906 | 907 | **Note:** the create action is default, so the second example is a more common 908 | usage. 909 | 910 | ##### Updating A Gemset 911 | 912 | rvm_gemset "jruby-1.6.0.RC2@development" do 913 | action :update 914 | end 915 | 916 | ##### Emptying A Gemset 917 | 918 | rvm_gemset "development" do 919 | ruby_string "jruby-1.6.3" 920 | action :empty 921 | end 922 | 923 | ##### Deleting A Gemset 924 | 925 | rvm_gemset "ruby-1.9.2-p136@rails" do 926 | action :delete 927 | end 928 | 929 | ### rvm_gem 930 | 931 | This resource is a close analog to the `gem_package` provider/resource which 932 | is RVM-aware. See the Opscode [package resource][package_resource] and 933 | [gem package options][gem_package_options] pages for more details. 934 | 935 | #### Actions 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 951 | 952 | 953 | 954 | 955 | 959 | 960 | 961 | 962 | 963 | 966 | 967 | 968 | 969 | 970 | 973 | 974 | 975 | 976 |
ActionDescriptionDefault
install 949 | Install a gem - if version is provided, install that specific version. 950 | Yes
upgrade 956 | Upgrade a gem - if version is provided, upgrade to that specific 957 | version 958 |  
remove 964 | Remove a gem. 965 |  
purge 971 | Purge a gem. 972 |  
977 | 978 | #### Attributes 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 994 | 995 | 996 | 997 | 998 | 1001 | 1002 | 1003 | 1004 | 1005 | 1008 | 1009 | 1010 | 1011 | 1012 | 1015 | 1016 | 1017 | 1018 | 1019 | 1022 | 1023 | 1024 | 1025 | 1026 | 1032 | 1033 | 1034 | 1035 |
AttributeDescriptionDefault Value
package_name 992 | Name attribute: the name of the gem to install. 993 | nil
version 999 | The specific version of the gem to install/upgrade. 1000 | nil
options 1006 | Add additional options to the underlying gem command. 1007 | nil
source 1013 | Provide an additional source for gem providers (such as RubyGems). 1014 | nil
gem_binary 1020 | A gem_package attribute to specify a gem binary. 1021 | "gem"
user 1027 | A users's isolated RVM installation on which to apply an action. The 1028 | default value of nil denotes a system-wide RVM 1029 | installation is being targeted. Note: if specified, the 1030 | user must already exist. 1031 | nil
1036 | 1037 | #### Examples 1038 | 1039 | ##### Install A Gem 1040 | 1041 | rvm_gem "thor" do 1042 | ruby_string "ruby-1.8.7-p352" 1043 | action :install 1044 | end 1045 | 1046 | rvm_gem "json" do 1047 | ruby_string "ruby-1.8.7-p330@awesome" 1048 | end 1049 | 1050 | rvm_gem "nokogiri" do 1051 | ruby_string "jruby-1.5.6" 1052 | version "1.5.0.beta.4" 1053 | action :install 1054 | end 1055 | 1056 | **Note:** the install action is default, so the second example is a more common 1057 | usage. Gemsets can also be specified. 1058 | 1059 | ##### Install A Gem From A Local File 1060 | 1061 | rvm_gem "json" do 1062 | ruby_string "ree@project" 1063 | source "/tmp/json-1.5.1.gem" 1064 | version "1.5.1" 1065 | end 1066 | 1067 | ##### Keep A Gem Up To Date 1068 | 1069 | rvm_gem "homesick" do 1070 | action :upgrade 1071 | end 1072 | 1073 | **Note:** the default RVM Ruby will be targeted if no `ruby_string` attribute 1074 | is given. 1075 | 1076 | ##### Remove A Gem 1077 | 1078 | rvm_gem "nokogiri" do 1079 | ruby_string "jruby-1.5.6" 1080 | version "1.4.4.2" 1081 | action :remove 1082 | end 1083 | 1084 | ### rvm_global_gem 1085 | 1086 | This resource will use the `rvm_gem` resource to manage a gem in the *global* 1087 | gemset accross all RVM Rubies. An entry will also be made/removed in RVM's 1088 | *global.gems* file. See the Opscode [package resource][package_resource] and 1089 | [gem package options][gem_package_options] pages for more details. 1090 | 1091 | #### Actions 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1108 | 1109 | 1110 | 1111 | 1112 | 1116 | 1117 | 1118 | 1119 | 1120 | 1123 | 1124 | 1125 | 1126 | 1127 | 1130 | 1131 | 1132 | 1133 |
ActionDescriptionDefault
install 1105 | Install a gem across all Rubies - if version is provided, install that 1106 | specific version. 1107 | Yes
upgrade 1113 | Upgrade a gem across all Rubies - if version is provided, upgrade to 1114 | that specific version. 1115 |  
remove 1121 | Remove a gem across all Rubies. 1122 |  
purge 1128 | Purge a gem across all Rubies. 1129 |  
1134 | 1135 | #### Attributes 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1151 | 1152 | 1153 | 1154 | 1155 | 1160 | 1161 | 1162 | 1163 | 1164 | 1167 | 1168 | 1169 | 1170 | 1171 | 1174 | 1175 | 1176 | 1177 | 1178 | 1183 | 1184 | 1185 | 1186 | 1187 | 1193 | 1194 | 1195 | 1196 |
AttributeDescriptionDefault Value
package_name 1149 | Name attribute: the name of the gem to install. 1150 | nil
ruby_string 1156 | An RVM Ruby string that could contain a gemset. If a gemset is given 1157 | (for example, "ruby-1.8.7-p330@awesome"), then it will 1158 | be used. 1159 | "default"
version 1165 | The specific version of the gem to install/upgrade. 1166 | nil
options 1172 | Add additional options to the underlying gem command. 1173 | nil
source 1179 | Provide an additional source for gem providers (such as RubyGems). 1180 | This can also include a file system path to a .gem file 1181 | such as /tmp/json-1.5.1.gem. 1182 | nil
user 1188 | A users's isolated RVM installation on which to apply an action. The 1189 | default value of nil denotes a system-wide RVM 1190 | installation is being targeted. Note: if specified, the 1191 | user must already exist. 1192 | nil
1197 | 1198 | ### rvm_shell 1199 | 1200 | This resource is a wrapper for the `script` resource which wraps the code block 1201 | in an RVM-aware environment.. See the Opscode 1202 | [script resource][script_resource] page for more details. 1203 | 1204 | #### Actions 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 |
ActionDescriptionDefault
runRun the scriptYes
nothingDo not run this command 
1227 | 1228 | Use `action :nothing` to set a command to only run if another resource 1229 | notifies it. 1230 | 1231 | #### Attributes 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | 1247 | 1248 | 1249 | 1250 | 1251 | 1256 | 1257 | 1258 | 1259 | 1260 | 1263 | 1264 | 1265 | 1266 | 1267 | 1271 | 1272 | 1273 | 1274 | 1275 | 1278 | 1279 | 1280 | 1281 | 1282 | 1285 | 1286 | 1287 | 1288 | 1289 | 1292 | 1293 | 1294 | 1295 | 1296 | 1299 | 1300 | 1301 | 1302 | 1303 | 1307 | 1308 | 1309 | 1310 | 1311 | 1314 | 1315 | 1316 | 1317 | 1318 | 1321 | 1322 | 1323 | 1324 | 1325 | 1331 | 1332 | 1333 | 1334 | 1335 | 1338 | 1339 | 1340 | 1341 |
AttributeDescriptionDefault Value
name 1245 | Name attribute: Name of the command to execute. 1246 | name
ruby_string 1252 | An RVM Ruby string that could contain a gemset. If a gemset is given 1253 | (for example, "ruby-1.8.7-p330@awesome"), then it will 1254 | be used. 1255 | "default"
code 1261 | Quoted script of code to execute. 1262 | nil
creates 1268 | A file this command creates - if the file exists, the command will not 1269 | be run. 1270 | nil
cwd 1276 | Current working director to run the command from. 1277 | nil
environment 1283 | A hash of environment variables to set before running this command. 1284 | nil
group 1290 | A group or group ID that we should change to before running this command. 1291 | nil
path 1297 | An array of paths to use when searching for the command. 1298 | nil, uses system path
returns 1304 | The return value of the command (may be an array of accepted values) - 1305 | this resource raises an exception if the return value(s) do not match. 1306 | 0
timeout 1312 | How many seconds to let the command run before timing out. 1313 | nil
user 1319 | A user name or user ID that we should change to before running this command. 1320 | nil
user 1326 | A users's isolated RVM installation on which to apply an action. The 1327 | default value of nil denotes a system-wide RVM 1328 | installation is being targeted. Note: if specified, the 1329 | user must already exist. 1330 | nil
umask 1336 | Umask for files created by the command. 1337 | nil
1342 | 1343 | #### Examples 1344 | 1345 | ##### Run A Rake Task 1346 | 1347 | rvm_shell "migrate_rails_database" do 1348 | ruby_string "1.8.7-p352@webapp" 1349 | user "deploy" 1350 | group "deploy" 1351 | cwd "/srv/webapp/current" 1352 | code %{rake RAILS_ENV=production db:migrate} 1353 | end 1354 | 1355 | ### rvm_wrapper 1356 | 1357 | This resource creates a wrapper script for a binary or list of binaries in 1358 | a given RVM Ruby (and optional gemset). The given Ruby will be installed if 1359 | it isn't already and a gemset will be created in none currently exist. 1360 | 1361 | #### Actions 1362 | 1363 | 1364 | 1365 | 1366 | 1367 | 1368 | 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 |
ActionDescriptionDefault
createCreates on or more wrapper scripts.Yes
1379 | 1380 | #### Attributes 1381 | 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1389 | 1390 | 1391 | 1392 | 1393 | 1396 | 1397 | 1398 | 1399 | 1400 | 1405 | 1406 | 1407 | 1408 | 1409 | 1413 | 1414 | 1415 | 1416 | 1417 | 1421 | 1422 | 1423 | 1424 | 1425 | 1431 | 1432 | 1433 | 1434 |
AttributeDescriptionDefault Value
prefix 1394 | Name attribute: a prefix string for the wrapper script name. 1395 | nil
ruby_string 1401 | An RVM Ruby string that could contain a gemset. If a gemset is given 1402 | (for example, "ruby-1.8.7-p330@awesome"), then it will 1403 | be used. 1404 | nil
binary 1410 | A single binary to be wrapped. If this attribute is used do not set 1411 | values for the binaries attribute. 1412 | nil
binaries 1418 | A list of binaries to be wrapped. If this attribute is used do not set 1419 | a value for the binary attribute. 1420 | nil
user 1426 | A users's isolated RVM installation on which to apply an action. The 1427 | default value of nil denotes a system-wide RVM 1428 | installation is being targeted. Note: if specified, the user 1429 | must already exist. 1430 | nil
1435 | 1436 | **Note:** only `binary` or `binaries` should be used by themselves (never at 1437 | the same time). 1438 | 1439 | #### Examples 1440 | 1441 | ##### Wrapping A Ruby CLI 1442 | 1443 | rvm_wrapper "sys" do 1444 | ruby_string "jruby@utils" 1445 | binary "thor" 1446 | end 1447 | 1448 | This will create a wrapper script called `sys_thor` in the `bin` directory 1449 | under `node['rvm']['root_path']`. 1450 | 1451 | ##### Wrapping A List Of Binaries 1452 | 1453 | rvm_wrapper "test" do 1454 | ruby_string "default@testing" 1455 | binaries [ "rspec", "cucumber" ] 1456 | action :create 1457 | end 1458 | 1459 | ## Contributing 1460 | 1461 | * Source hosted at [GitHub][repo] 1462 | * Report issues/Questions/Feature requests on [GitHub Issues][issues] 1463 | 1464 | Pull requests are very welcome! Make sure your patches are well tested. 1465 | Ideally create a topic branch for every seperate change you make. 1466 | 1467 | ### Testing 1468 | 1469 | Make sure you have the following requirements setup: 1470 | 1471 | * [Vagrant](http://www.vagrantup.com/) 1472 | * [berkshelf-vagrant](https://github.com/riotgames/berkshelf-vagrant) 1473 | 1474 | After you `bundle install` just run `kitchen test` 1475 | 1476 | ## License and Author 1477 | 1478 | Author:: [Fletcher Nichol][fnichol] () [![endorse](http://api.coderwall.com/fnichol/endorsecount.png)](http://coderwall.com/fnichol) 1479 | 1480 | 1481 | Contributors:: https://github.com/fnichol/chef-rvm/contributors 1482 | 1483 | Copyright:: 2010, 2011, Fletcher Nichol 1484 | 1485 | Licensed under the Apache License, Version 2.0 (the "License"); 1486 | you may not use this file except in compliance with the License. 1487 | You may obtain a copy of the License at 1488 | 1489 | http://www.apache.org/licenses/LICENSE-2.0 1490 | 1491 | Unless required by applicable law or agreed to in writing, software 1492 | distributed under the License is distributed on an "AS IS" BASIS, 1493 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1494 | See the License for the specific language governing permissions and 1495 | limitations under the License. 1496 | 1497 | [berkshelf]: http://berkshelf.com 1498 | [chef_gem_cb]: http://community.opscode.com/cookbooks/chef_gem 1499 | [chef_repo]: https://github.com/opscode/chef-repo 1500 | [cheffile]: https://github.com/applicationsonline/librarian/blob/master/lib/librarian/chef/templates/Cheffile 1501 | [compilation]: http://wiki.opscode.com/display/chef/Evaluate+and+Run+Resources+at+Compile+Time 1502 | [dragons]: http://en.wikipedia.org/wiki/Here_be_dragons 1503 | [gem_package]: http://wiki.opscode.com/display/chef/Resources#Resources-Package 1504 | [gem_package_options]: http://wiki.opscode.com/display/chef/Resources#Resources-GemPackageOptions 1505 | [gh50]: https://github.com/fnichol/chef-rvm/issues/50 1506 | [fnichol]: https://github.com/fnichol 1507 | [java_cb]: http://community.opscode.com/cookbooks/java 1508 | [jruby]: http://jruby.org/ 1509 | [kgc]: https://github.com/websterclay/knife-github-cookbooks#readme 1510 | [librarian]: https://github.com/applicationsonline/librarian#readme 1511 | [lwrp]: http://wiki.opscode.com/display/chef/Lightweight+Resources+and+Providers+%28LWRP%29 1512 | [package_resource]: http://wiki.opscode.com/display/chef/Resources#Resources-Package 1513 | [rvm]: https://rvm.io 1514 | [rvm_create_gemset]: https://rvm.io/gemsets/creating/ 1515 | [rvm_delete_gemset]: https://rvm.io/gemsets/deleting/ 1516 | [rvm_empty_gemset]: https://rvm.io/gemsets/emptying/ 1517 | [rvm_default]: https://rvm.io/rubies/default/ 1518 | [rvm_gemsets]: https://rvm.io/gemsets/ 1519 | [rvm_install]: https://rvm.io/rubies/installing/ 1520 | [rvm_remove]: https://rvm.io/rubies/removing/ 1521 | [rvm_upgrading]: https://rvm.io/rvm/upgrading/ 1522 | [script_resource]: http://wiki.opscode.com/display/chef/Resources#Resources-Script 1523 | [vagrant]: http://vagrantup.com 1524 | 1525 | [repo]: https://github.com/fnichol/chef-rvm 1526 | [issues]: https://github.com/fnichol/chef-rvm/issues 1527 | --------------------------------------------------------------------------------