diff --git a/.editorconfig b/.editorconfig
deleted file mode 100755
index cc21b046..00000000
--- a/.editorconfig
+++ /dev/null
@@ -1,19 +0,0 @@
-# https://EditorConfig.org
-
-# top-most EditorConfig file
-root=true
-
-# Unix-style newlines with a newline ending every file
-[*]
-end_of_line = lf
-insert_final_newline = true
-
-# 2 space indentation
-indent_style = space
-indent_size = 2
-
-# Avoid issues parsing cookbook files later
-charset = utf-8
-
-# Avoid cookstyle warnings
-trim_trailing_whitespace = true
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 69014cbb..fc928130 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -4,8 +4,7 @@ name: ci
"on":
pull_request:
push:
- branches:
- - main
+ branches: [main]
jobs:
lint-unit:
@@ -23,10 +22,14 @@ jobs:
strategy:
matrix:
os:
- - "centos-7"
- - "debian-9"
- - "ubuntu-1604"
- - "ubuntu-1804"
+ - amazonlinux-2
+ - debian-9
+ - debian-10
+ - debian-11
+ - centos-7
+ - centos-8
+ - ubuntu-1804
+ - ubuntu-2004
suite:
- "server-install"
fail-fast: false
diff --git a/Berksfile b/Berksfile
index 159bc746..e09849c7 100644
--- a/Berksfile
+++ b/Berksfile
@@ -3,9 +3,5 @@ source 'https://supermarket.chef.io'
metadata
group :integration do
- cookbook 'apt'
- cookbook 'yum'
- cookbook 'java'
- cookbook 'user'
- cookbook 'rvm_wrapper', path: 'test/fixtures/cookbooks/rvm_wrapper'
+ cookbook 'test', path: 'test/fixtures/cookbooks/test'
end
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 26431220..dd195a04 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
+- Rename test cookbook to test
+- Testing Updates
+ - Remove test users databag
+- Remove Foodcritic config
+ - Foodcritic has been replace by Cookstyle
+- Require Chef 15.3 for unified_mode and Chef 18 support
+- Move the vagrant recipe to the test cookbook
+ - This recipe this is only for testing
+- Move all recipes to resource
+ - This allows us to use unifed_mode to install gems in the correct order
+
## 2.0.4 - *2023-09-29*
## 2.0.3 - *2023-09-04*
diff --git a/README.md b/README.md
index c2e79227..d7f6a059 100644
--- a/README.md
+++ b/README.md
@@ -1,162 +1,40 @@
-# RVM
+# RVM Cookbook
- chef-rvm [![Build Status](https://secure.travis-ci.org/martinisoft/chef-rvm.png?branch=master)](http://travis-ci.org/martinisoft/chef-rvm)
-
-**WARNING** - Please read!
-
-There is currently a _major_ rewrite going on with this cookbook to simplify
-the interface to RVM with Chef. Expect the master branch to be very broken
-until there is a 1.0 release. All previous pull requests will need to rebase
-to the newer master to contribute to the newly re-factored resources.
-
-## Description
+[![Cookbook Version](https://img.shields.io/cookbook/v/rvm.svg)](https://supermarket.chef.io/cookbooks/rvm)
+[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers)
+[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
+[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
Manages system-wide and per-user [RVM][rvm]s and manages installed Rubies.
-Several resources are defined to accomplish these tasks.
-
-## Requirements
-### Chef
+## Requirements
-Tested on 12.5.1 but older versions of chef may not work due to the changes
-in the resource model. You are welcome to submit a pull request to add this
-support.
+- Chef 15.3+
-File an [issue][issues] if this isn't the case.
+### Platforms
-### Platform
-
-The following platforms have been tested with this cookbook, meaning that
-the recipes and LWRPs run on these platforms without error:
-
-* ubuntu (12.04 and higher)
-* debian (6.0 and newer)
-* mac_os_x (10.6/10.7) (See [Platform Notes](#platform-notes-osx))
-* mac_os_x_server (See [Platform Notes](#platform-notes-osx))
-* suse (openSUSE, SLES)
-* centos
-* amazon (2011.09)
-* scientific
-* redhat
-* fedora
-* gentoo
-
-Please [report][issues] any additional platforms so they can be added.
+- Debian, Ubuntu
+- CentOS, RedHat, Fedora, Scientific, Amazon
### Platform Notes
-#### OSX
-
-This cookbook suggests the [homebrew](http://community.opscode.com/cookbooks/homebrew) cookbook, which is needed to install
-any additional packages needed to compile ruby. RVM now ships binary rubies,
-but will require homebrew to install any additional libraries.
-
-### Cookbooks
-
-If you are installing [JRuby][jruby] then a Java runtime will need to be
-installed. The Opscode [java cookbook][java_cb] can be used on supported
-platforms.
-
-## Installation
+## Installation
Depending on the situation and use case there are several ways to install
this cookbook. All the methods listed below assume a tagged version release
is the target, but omit the tags to get the head of development. A valid
Chef repository structure like the [Opscode repo][chef_repo] is also assumed.
-### Using Berkshelf
-
-[Berkshelf][berkshelf] is a way to manage a cookbook or an application's
-cookbook dependencies. Include the cookbook in your Berksfile, and then run
-`berks install`. To install using Berkshelf:
-
-```shell
- gem install berkshelf
- cd chef-repo
- berks init
- echo "cookbook 'rvm', github: 'fnichol/chef-rvm'" >> Berksfile
- berks install
-```
-
-### Using Librarian-Chef
-
-[Librarian-Chef][librarian] is a bundler for your Chef cookbooks.
-Include a reference to the cookbook in a [Cheffile][cheffile] and run
-`librarian-chef install`. To install Librarian-Chef:
-
-```shell
- gem install librarian-chef
- cd chef-repo
- librarian-chef init
- cat >> Cheffile < 'git://github.com/fnichol/chef-rvm.git', :ref => 'v0.10.1'
- END_OF_CHEFFILE
- librarian-chef install
-```
+## Resources
-## Recipes
+- [rvm_system_install](documentation/rvm_system_install.md)
+- [rvm_user_install](documentation/rvm_user_install.md)
+- [rvm_ruby](documentation/rvm_ruby.md)
+- [rvm_gem](documentation/rvm_gem.md)
+- [rvm_gemset](documentation/rvm_gem_set.md)
+- [rvm_alias](documentation/rvm_alias.md)
+- [rvm_wrapper](documentation/rvm_wrapper.md)
-### default
-
-Installs the RVM gem and initializes Chef to use the Resources in this cookbook
-for installing and managing RVM.
-
-## Contributing
+## Contributing
See the CONTRIBUTING.md file
-
-### Testing
-
-Make sure you have the following requirements setup:
-
-* [Vagrant][vagrant]
-* [vagrant-berkshelf][vagrant-berkshelf]
-
-After you `bundle install` run `rake` for unit tests and `kitchen test` for
-integration level tests.
-
-## License and Authors
-
-Authors:: [Aaron Kalin][martinisoft] ()
-
-Contributors::
-
-Copyright:: 2010 - 2017, Aaron Kalin
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-[berkshelf]: http://berkshelf.com
-[chef_repo]: https://github.com/chef/chef
-[cheffile]: https://github.com/applicationsonline/librarian/blob/master/lib/librarian/chef/templates/Cheffile
-[compilation]: http://wiki.opscode.com/display/chef/Evaluate+and+Run+Resources+at+Compile+Time
-[dragons]: http://en.wikipedia.org/wiki/Here_be_dragons
-[martinisoft]: https://github.com/martinisoft
-[java_cb]: http://supermarket.chef.io/cookbooks/java
-[jruby]: http://jruby.org/
-[librarian]: https://github.com/applicationsonline/librarian#readme
-[rvm]: https://rvm.io
-[rvm_create_gemset]: https://rvm.io/gemsets/creating/
-[rvm_delete_gemset]: https://rvm.io/gemsets/deleting/
-[rvm_empty_gemset]: https://rvm.io/gemsets/emptying/
-[rvm_default]: https://rvm.io/rubies/default/
-[rvm_gemsets]: https://rvm.io/gemsets/
-[rvm_install]: https://rvm.io/rvm/install/
-[rvm_remove]: https://rvm.io/rubies/removing/
-[rvm_ruby_install]: https://rvm.io/rubies/installing/
-[rvm_upgrading]: https://rvm.io/rvm/upgrading/
-[vagrant]: http://vagrantup.com
-[vagrant-berkshelf]: https://github.com/berkshelf/vagrant-berkshelf
-
-[repo]: https://github.com/sous-chefs/chef-rvm
-[issues]: https://github.com/sous-chefs/chef-rvm/issues
diff --git a/TODO.md b/TODO.md
new file mode 100644
index 00000000..fbac0af4
--- /dev/null
+++ b/TODO.md
@@ -0,0 +1,10 @@
+# TODO
+
+How we're going to go about fixing RVM!
+
+- Install one Ruby
+-
+
+## Use a Mixed mode installation
+
+- For an installation usable by all users on the system - with isolated rubies/gemsets within a user's $HOME. Installation instructions are exactly the same as for Multi-User installations, the difference is in users environment.
diff --git a/attributes/default.rb b/attributes/default.rb
index 989a6bfd..248d312c 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -1,24 +1,3 @@
-#
-# Cookbook:: rvm
-# Attributes:: default
-#
-# Author:: Fletcher Nichol
-#
-# Copyright:: 2010, 2011, Fletcher Nichol
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
# ruby that will get installed and set to `rvm use default`.
default['rvm']['default_ruby'] = 'ruby-1.9.3-p547'
default['rvm']['user_default_ruby'] = 'ruby-1.9.3-p547'
@@ -39,7 +18,7 @@
default['rvm']['user_gems'] = {}
# hash of rvmrc options
-default['rvm']['rvmrc_env'] = { 'rvm_gem_options' => '--no-ri --no-rdoc' }
+default['rvm']['rvmrc_env'] = { 'rvm_gem_options' => '--no-document' }
# a hash of user hashes, each an isolated per-user RVM installation
default['rvm']['installs'] = {}
@@ -48,17 +27,11 @@
default['rvm']['installer_url'] = 'https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer'
default['rvm']['version'] = 'stable'
-# GPG key for rvm verification
-default['rvm']['gpg_key'] = 'D39DC0E3'
-default['rvm']['gpg_key_server'] = 'hkp://keys.gnupg.net'
-
# Autolib mode, see https://rvm.io/rvm/autolibs
default['rvm']['autolib_mode'] = 3
# extra system-wide tunables
-default['rvm']['root_path'] = '/usr/local/rvm'
-default['rvm']['group_id'] = 'default'
-default['rvm']['group_users'] = []
+default['rvm']['root_path'] = '/usr/local/rvm'
case node['platform']
when 'redhat', 'centos', 'fedora', 'scientific', 'amazon', 'oracle'
diff --git a/recipes/.gitkeep b/documentation/rvm_alias.md
similarity index 100%
rename from recipes/.gitkeep
rename to documentation/rvm_alias.md
diff --git a/documentation/rvm_gem.md b/documentation/rvm_gem.md
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/documentation/rvm_gem.md
@@ -0,0 +1 @@
+
diff --git a/documentation/rvm_gem_set.md b/documentation/rvm_gem_set.md
new file mode 100644
index 00000000..e69de29b
diff --git a/documentation/rvm_ruby.md b/documentation/rvm_ruby.md
new file mode 100644
index 00000000..e69de29b
diff --git a/documentation/rvm_system.md b/documentation/rvm_system.md
new file mode 100644
index 00000000..e69de29b
diff --git a/documentation/rvm_system_install.md b/documentation/rvm_system_install.md
new file mode 100644
index 00000000..e69de29b
diff --git a/documentation/rvm_user.md b/documentation/rvm_user.md
new file mode 100644
index 00000000..e69de29b
diff --git a/documentation/rvm_user_install.md b/documentation/rvm_user_install.md
new file mode 100644
index 00000000..e69de29b
diff --git a/documentation/rvm_wrapper.md b/documentation/rvm_wrapper.md
new file mode 100644
index 00000000..e69de29b
diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml
index 47eff95d..4e6938d2 100644
--- a/kitchen.dokken.yml
+++ b/kitchen.dokken.yml
@@ -7,7 +7,7 @@ transport: { name: dokken }
provisioner: { name: dokken }
platforms:
- - name: almalinux-8
+ - name: debian-9
driver:
image: dokken/almalinux-8
pid_one_command: /usr/lib/systemd/systemd
diff --git a/kitchen.yml b/kitchen.yml
index ec6f91de..04d3f232 100644
--- a/kitchen.yml
+++ b/kitchen.yml
@@ -1,52 +1,29 @@
---
-driver_plugin: vagrant
-driver_config:
- require_chef_omnibus: true
+driver:
+ name: vagrant
+
+provisioner:
+ product_name: chef
+ product_version: <%= ENV['CHEF_VERSION'] || 'latest' %>
+ install_strategy: once
+ deprecations_as_errors: true
+
+verifier:
+ name: inspec
+
platforms:
- -
- name: ubuntu-14.04
- run_list:
- - 'recipe[apt]'
- -
- name: ubuntu-12.04
- run_list:
- - 'recipe[apt]'
- -
- name: ubuntu-10.04
- run_list:
- - 'recipe[apt]'
- -
- name: debian-7.6
- -
- name: centos-6.4
+ - name: centos-7
+ - name: centos-8
+ - name: fedora-latest
+ - name: debian-9
+ - name: debian-10
+ - name: ubuntu-18.04
+ - name: ubuntu-20.04
+ - name: opensuse-leap
+
suites:
- -
- name: stock_system_and_user
- run_list:
- - 'recipe[user::data_bag]'
- - 'recipe[rvm::system]'
- - 'recipe[rvm::user]'
- attributes:
- users: [wigglebottom]
- rvm: {user_installs: [{user: wigglebottom, default_ruby: 2.1.5}]}
- -
- name: rubies
- run_list:
- - 'recipe[java]'
- - 'recipe[rvm::system]'
- attributes:
- rvm: {default_ruby: system, rubies: [2.1.5, jruby, ree]}
- -
- name: rbx
- run_list:
- - 'recipe[rvm::system]'
- attributes:
- rvm: {default_ruby: rbx}
- -
- name: installs
- run_list:
- - 'recipe[user::data_bag]'
- - 'recipe[rvm::user_install]'
- attributes:
- users: [virgil1, virgil2]
- rvm: {installs: {virgil1: {installer_flags: '--version 1.19.6'}, virgil2: {installer_flags: '--version 1.21.20'}}} # yamllint disable-line
+ - name: system_install
+ run_list: recipe[test::system_install]
+
+ - name: user_install
+ run_list: recipe[test::user_install]
diff --git a/libraries/provider_rvm_ruby.rb b/libraries/provider_rvm_ruby.rb
deleted file mode 100644
index 88a4a9ae..00000000
--- a/libraries/provider_rvm_ruby.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'chef/provider/lwrp_base'
-
-class Chef
- class Provider
- class RvmRuby < Chef::Provider::LWRPBase
- provides :rvm_ruby
-
- action :install do
- remote_file 'rvm_installer' do
- path "#{Chef::Config[:file_cache_path]}/rvm_installer.sh"
- source node['rvm']['installer_url']
- mode '755'
- action :create_if_missing
- end
- end
- end
- end
-end
diff --git a/libraries/resource_rvm_ruby.rb b/libraries/resource_rvm_ruby.rb
deleted file mode 100644
index 5655ed3c..00000000
--- a/libraries/resource_rvm_ruby.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'chef/resource/lwrp_base'
-
-class Chef
- class Resource
- class RvmRuby < Chef::Resource::LWRPBase
- provides :rvm_ruby
-
- self.resource_name = :rvm_ruby
- default_action :install
- end
- end
-end
diff --git a/recipes/default.rb b/recipes/default.rb
deleted file mode 100644
index 5311c2b4..00000000
--- a/recipes/default.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Cookbook:: rvm
-# Recipe:: default
-#
-# Copyright:: 2010, 2011, Fletcher Nichol
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# install rvm api gem during chef compile phase
-chef_gem 'rvm' do
- action :install
- version '>= 1.11.3.6'
-end
-require 'rvm'
-
-create_rvm_shell_chef_wrapper
-create_rvm_chef_user_environment
-
-class Chef::Resource
- # mix in #rvm_cmd_wrap helper into resources
- include Chef::RVM::ShellHelpers
-end
-
-class Chef::Recipe
- # mix in recipe helpers
- include Chef::RVM::ShellHelpers
- include Chef::RVM::RecipeHelpers
- include Chef::RVM::StringHelpers
-end
diff --git a/recipes/gem_package.rb b/recipes/gem_package.rb
deleted file mode 100644
index f832612e..00000000
--- a/recipes/gem_package.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Cookbook:: rvm
-# Recipe:: gem_package
-#
-# Copyright:: 2011, Fletcher Nichol
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-node_val = node['rvm']['gem_package']['rvm_string']
-case node_val
-when String
- rvm_descriptor = node_val + ' RVM Ruby'
-when Array
- last = node_val.pop
- rvm_descriptor = [ node_val.join(', '), last ].join(' & ') + ' RVM Rubies'
-end
-
-patch_gem_package
-
-::Chef::Log.info 'gem_package resource has been patched to use provider ' \
- 'Chef::Provider::Package::RVMRubygems and will install gems to ' \
- "the #{rvm_descriptor}."
diff --git a/recipes/system.rb b/recipes/system.rb
deleted file mode 100644
index 41281159..00000000
--- a/recipes/system.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Cookbook:: rvm
-# Recipe:: system
-#
-# Copyright:: 2010, 2011 Fletcher Nichol
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include_recipe 'rvm::system_install'
-
-perform_install_rubies = node['rvm']['install_rubies'] == true ||
- node['rvm']['install_rubies'] == 'true'
-
-if perform_install_rubies
- install_rubies rubies: node['rvm']['rubies'],
- default_ruby: node['rvm']['default_ruby'],
- global_gems: node['rvm']['global_gems'],
- gems: node['rvm']['gems']
-end
-
-# add users to rvm group
-group 'rvm' do
- members node['rvm']['group_users']
-
- only_if { node['rvm']['group_users'].any? }
-end
diff --git a/recipes/system_install.rb b/recipes/system_install.rb
deleted file mode 100644
index 57f97554..00000000
--- a/recipes/system_install.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Cookbook:: rvm
-# Recipe:: system_install
-#
-# Copyright:: 2010, 2011 Fletcher Nichol
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include_recipe 'rvm'
-
-# Build the rvm group ahead of time, if it is set. This allows avoiding
-# collision with later processes which may set a guid explicitly
-if node['rvm']['group_id'] != 'default'
- g = group 'rvm' do
- group_name 'rvm'
- gid node['rvm']['group_id']
- action :nothing
- end
- g.run_action(:create)
-end
-
-key_server = node['rvm']['gpg']['keyserver'] || 'hkp://keys.gnupg.net'
-home_dir = "#{node['rvm']['gpg']['homedir'] || '~'}/.gnupg"
-
-execute 'Adding gpg key' do
- command "`which gpg2 || which gpg` --keyserver #{key_server} --homedir #{home_dir} --recv-keys #{node['rvm']['gpg_key']}"
- only_if 'which gpg2 || which gpg'
- not_if { node['rvm']['gpg_key'].empty? }
-end
-
-rvm_installation('root')
diff --git a/recipes/user.rb b/recipes/user.rb
deleted file mode 100644
index 84f3851a..00000000
--- a/recipes/user.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Cookbook:: rvm
-# Recipe:: user
-#
-# Copyright:: 2011 Fletcher Nichol
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include_recipe 'rvm::user_install'
-
-Array(node['rvm']['user_installs']).each do |rvm_user|
- perform_install_rubies = rvm_user['install_rubies'] == true ||
- rvm_user['install_rubies'] == 'true' ||
- node['rvm']['user_install_rubies'] == true ||
- node['rvm']['user_install_rubies'] == 'true'
- rubies = rvm_user['rubies'] ||
- node['rvm']['user_rubies']
- default_ruby = rvm_user['default_ruby'] ||
- node['rvm']['user_default_ruby']
- global_gems = rvm_user['global_gems'] ||
- node['rvm']['user_global_gems']
- gems = rvm_user['gems'] ||
- node['rvm']['user_gems']
-
- next unless perform_install_rubies
- install_rubies rubies: rubies,
- default_ruby: default_ruby,
- global_gems: global_gems,
- gems: gems,
- user: rvm_user['user']
-end
diff --git a/recipes/user_install.rb b/recipes/user_install.rb
deleted file mode 100644
index a116991a..00000000
--- a/recipes/user_install.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Cookbook:: rvm
-# Recipe:: user_install
-#
-# Copyright:: 2011, 2012, 2013 Fletcher Nichol
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include_recipe 'rvm'
-
-node['rvm']['installs'].each do |user, opts|
- # if user hash is falsy (nil, false) then we're not installing
- next unless opts
-
- # if user hash is not a hash (i.e. set to true), init an empty Hash
- opts = {} if opts == true
-
- ruby_block 'Conditionally add RVM gpg key' do
- block do
- cmd = Mixlib::ShellOut.new('which gpg2 || which gpg')
- cmd.run_command
-
- if cmd.exitstatus == 0
- gpg_command = cmd.stdout.chomp
-
- exec = Chef::Resource::Execute.new 'Add RVM gpg key', run_context
- exec.command "#{gpg_command} --keyserver hkp://keys.gnupg.net --recv-keys #{node['rvm']['gpg_key']}"
- exec.user user['user']
- exec.environment 'HOME' => user['home']
- exec.guard_interpreter :bash
- exec.not_if "#{gpg_command} -k #{node['rvm']['gpg_key']} > /dev/null", user: user['user'], environment: { 'HOME' => user['home'] }
- exec.run_action :run
- else
- Chef::Log.info 'Skipping adding RVM key because gpg/gpg2 not installed'
- end
- end
- end
-
- rvm_installation(user.to_s) do
- %w(installer_url installer_flags install_pkgs rvmrc_template_source
- rvmrc_template_cookbook rvmrc_env action
- ).each do |attr|
- # if user hash attr is set, then set the resource attr
- send(attr, opts[attr]) if opts.fetch(attr, false)
- end
- end
-end
diff --git a/recipes/vagrant.rb b/recipes/vagrant.rb
deleted file mode 100644
index 691ca6c6..00000000
--- a/recipes/vagrant.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Cookbook:: rvm
-# Recipe:: vagrant
-#
-# Copyright:: 2011, Fletcher Nichol
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-template '/usr/local/bin/chef-client' do
- source 'vagrant-chef-client-wrapper.erb'
- owner 'root'
- group 'root'
- mode '0755'
-end
-
-template '/usr/local/bin/chef-solo' do
- source 'vagrant-chef-solo-wrapper.erb'
- owner 'root'
- group 'root'
- mode '0755'
-end
-
-group 'rvm' do
- members ['vagrant']
- append true
-end
diff --git a/resources/alias.rb b/resources/alias.rb
new file mode 100644
index 00000000..e69de29b
diff --git a/resources/gem.rb b/resources/gem.rb
new file mode 100644
index 00000000..6363cab7
--- /dev/null
+++ b/resources/gem.rb
@@ -0,0 +1,27 @@
+unified_mode true
+
+property :package_name,
+ String,
+ name_property: true
+
+property :version,
+ String
+
+property :ruby_string,
+ String,
+ default: 'default'
+
+property :response_file,
+ String
+
+property :source,
+ String
+
+property :options,
+ Hash
+
+property :gem_binary,
+ String
+
+property :user,
+ String
diff --git a/resources/gem_set.rb b/resources/gem_set.rb
new file mode 100644
index 00000000..77b27494
--- /dev/null
+++ b/resources/gem_set.rb
@@ -0,0 +1,18 @@
+unified_mode true
+
+action :install do
+ node_val = node['rvm']['gem_package']['rvm_string']
+ case node_val
+ when String
+ rvm_descriptor = node_val + ' RVM Ruby'
+ when Array
+ last = node_val.pop
+ rvm_descriptor = [ node_val.join(', '), last ].join(' & ') + ' RVM Rubies'
+ end
+
+ patch_gem_package
+
+ ::Chef::Log.info 'gem_package resource has been patched to use provider ' \
+ 'Chef::Provider::Package::RVMRubygems and will install gems to ' \
+ "the #{rvm_descriptor}."
+end
diff --git a/resources/ruby.rb b/resources/ruby.rb
new file mode 100644
index 00000000..35107015
--- /dev/null
+++ b/resources/ruby.rb
@@ -0,0 +1,12 @@
+unified_mode true
+
+property :installer_url, String, default: lazy { node['rvm']['installer_url'] }
+
+action :install do
+ remote_file 'rvm_installer' do
+ path "#{Chef::Config[:file_cache_path]}/rvm_installer.sh"
+ source new_resource.installer_url
+ mode '755'
+ action :create_if_missing
+ end
+end
diff --git a/resources/system.rb b/resources/system.rb
new file mode 100644
index 00000000..cb78575e
--- /dev/null
+++ b/resources/system.rb
@@ -0,0 +1,20 @@
+unified_mode true
+
+include_recipe 'rvm::system_install'
+
+perform_install_rubies = node['rvm']['install_rubies'] == true ||
+ node['rvm']['install_rubies'] == 'true'
+
+if perform_install_rubies
+ install_rubies rubies: node['rvm']['rubies'],
+ default_ruby: node['rvm']['default_ruby'],
+ global_gems: node['rvm']['global_gems'],
+ gems: node['rvm']['gems']
+end
+
+# add users to rvm group
+group 'rvm' do
+ members node['rvm']['group_users']
+
+ only_if { node['rvm']['group_users'].any? }
+end
diff --git a/resources/system_install.rb b/resources/system_install.rb
new file mode 100644
index 00000000..f4609752
--- /dev/null
+++ b/resources/system_install.rb
@@ -0,0 +1,17 @@
+unified_mode true
+property :key_server, String, default: 'hkp://pool.sks-keyservers.net'
+property :gpg_homedir, String, default: '~/.gnupg'
+property :gpg_key, String, default: '409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB'
+
+action :install do
+ group 'rvm'
+
+ gpg_install
+
+ execute 'Adding gpg key' do
+ command "`which gpg2 || which gpg` --keyserver #{new_resource.key_server} --homedir #{new_resource.gpg_homedir} --recv-keys #{new_resource.gpg_key}"
+ only_if 'which gpg2 || which gpg'
+ end
+
+ rvm_installation('root')
+end
diff --git a/resources/user.rb b/resources/user.rb
new file mode 100644
index 00000000..7d0f7e80
--- /dev/null
+++ b/resources/user.rb
@@ -0,0 +1,27 @@
+unified_mode true
+
+action :install do
+ include_recipe 'rvm::user_install'
+
+ Array(node['rvm']['user_installs']).each do |rvm_user|
+ perform_install_rubies = rvm_user['install_rubies'] == true ||
+ rvm_user['install_rubies'] == 'true' ||
+ node['rvm']['user_install_rubies'] == true ||
+ node['rvm']['user_install_rubies'] == 'true'
+ rubies = rvm_user['rubies'] ||
+ node['rvm']['user_rubies']
+ default_ruby = rvm_user['default_ruby'] ||
+ node['rvm']['user_default_ruby']
+ global_gems = rvm_user['global_gems'] ||
+ node['rvm']['user_global_gems']
+ gems = rvm_user['gems'] ||
+ node['rvm']['user_gems']
+
+ next unless perform_install_rubies
+ install_rubies rubies: rubies,
+ default_ruby: default_ruby,
+ global_gems: global_gems,
+ gems: gems,
+ user: rvm_user['user']
+ end
+end
diff --git a/resources/user_install.rb b/resources/user_install.rb
new file mode 100644
index 00000000..6890e809
--- /dev/null
+++ b/resources/user_install.rb
@@ -0,0 +1,42 @@
+unified_mode true
+
+action :install do
+ chef_gem 'rvm' do
+ action :install
+ version '>= 1.11.3.6'
+ end
+
+ require 'rvm'
+
+ create_rvm_shell_chef_wrapper
+ create_rvm_chef_user_environment
+
+ include Chef::RVM::ShellHelpers
+ include Chef::RVM::StringHelpers
+
+ cmd = Mixlib::ShellOut.new('which gpg2 || which gpg')
+ cmd.run_command
+
+ if cmd.exitstatus == 0
+ gpg_command = cmd.stdout.chomp
+
+ exec = Chef::Resource::Execute.new 'Add RVM gpg key', run_context
+ exec.command "#{gpg_command} --keyserver hkp://keys.gnupg.net --recv-keys #{node['rvm']['gpg_key']}"
+ exec.user user['user']
+ exec.environment 'HOME' => user['home']
+ exec.guard_interpreter :bash
+ exec.not_if "#{gpg_command} -k #{node['rvm']['gpg_key']} > /dev/null", user: user['user'], environment: { 'HOME' => user['home'] }
+ exec.run_action :run
+ else
+ Chef::Log.info 'Skipping adding RVM key because gpg/gpg2 not installed'
+ end
+
+ rvm_installation(user.to_s) do
+ %w(installer_url installer_flags install_pkgs rvmrc_template_source
+ rvmrc_template_cookbook rvmrc_env action
+ ).each do |attr|
+ # if user hash attr is set, then set the resource attr
+ send(attr, opts[attr]) if opts.fetch(attr, false)
+ end
+ end
+end
diff --git a/resources/wrapper.rb b/resources/wrapper.rb
new file mode 100644
index 00000000..e69de29b
diff --git a/spec/libraries/provider_rvm_ruby_spec.rb b/spec/libraries/provider_rvm_ruby_spec.rb
deleted file mode 100644
index 0ea21ab7..00000000
--- a/spec/libraries/provider_rvm_ruby_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'spec_helper'
-
-describe 'rvm_ruby' do
- let(:rvm_ruby_default) do
- ChefSpec::SoloRunner.new(
- platform: 'ubuntu',
- step_into: ['rvm_ruby']
- ).converge('rvm_wrapper::default')
- end
-
- context 'without rvm installed' do
- it 'fetches the latest installer' do
- expect(rvm_ruby_default).to create_if_missing_remote_file("#{Chef::Config[:file_cache_path]}/rvm_installer.sh")
- end
- end
-end
diff --git a/spec/resources/rvm_ruby_spec.rb b/spec/resources/rvm_ruby_spec.rb
new file mode 100644
index 00000000..2164271a
--- /dev/null
+++ b/spec/resources/rvm_ruby_spec.rb
@@ -0,0 +1,4 @@
+require 'spec_helper'
+
+# describe 'rvm_ruby' do
+# end
diff --git a/test/fixtures/cookbooks/rvm_wrapper/README.md b/test/fixtures/cookbooks/rvm_wrapper/README.md
deleted file mode 100644
index 2f4b8aae..00000000
--- a/test/fixtures/cookbooks/rvm_wrapper/README.md
+++ /dev/null
@@ -1 +0,0 @@
-This is a wrapper cookbook meant to test various configurations of chef-rvm
diff --git a/test/fixtures/cookbooks/rvm_wrapper/recipes/default.rb b/test/fixtures/cookbooks/rvm_wrapper/recipes/default.rb
deleted file mode 100644
index 0f849502..00000000
--- a/test/fixtures/cookbooks/rvm_wrapper/recipes/default.rb
+++ /dev/null
@@ -1 +0,0 @@
-rvm_ruby '2.3.0'
diff --git a/test/fixtures/cookbooks/test/README.md b/test/fixtures/cookbooks/test/README.md
new file mode 100644
index 00000000..bcf5128d
--- /dev/null
+++ b/test/fixtures/cookbooks/test/README.md
@@ -0,0 +1,3 @@
+# Test Cookbook
+
+This is a wrapper cookbook to test various configurations of the RVM cookbook
diff --git a/test/fixtures/cookbooks/rvm_wrapper/metadata.rb b/test/fixtures/cookbooks/test/metadata.rb
similarity index 60%
rename from test/fixtures/cookbooks/rvm_wrapper/metadata.rb
rename to test/fixtures/cookbooks/test/metadata.rb
index 3d4e37de..c97b788b 100644
--- a/test/fixtures/cookbooks/rvm_wrapper/metadata.rb
+++ b/test/fixtures/cookbooks/test/metadata.rb
@@ -1,4 +1,3 @@
-name 'rvm_wrapper'
+name 'test'
version '0.0.1'
-
depends 'rvm'
diff --git a/test/fixtures/cookbooks/test/recipes/custom_group_install.rb b/test/fixtures/cookbooks/test/recipes/custom_group_install.rb
new file mode 100644
index 00000000..a8ed4c7f
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/custom_group_install.rb
@@ -0,0 +1,28 @@
+# Install rbenv and makes it avilable to the selected user
+version = '2.4.1'
+
+# Make sure that Vagarant user is on the box for dokken
+include_recipe 'test::dokken'
+
+group 'new-group' do
+ members 'vagrant'
+end
+
+# Keeps the rbenv install upto date
+rbenv_user_install 'vagrant' do
+ user 'vagrant'
+ group 'new-group'
+end
+
+rbenv_plugin 'ruby-build' do
+ git_url 'https://github.com/rbenv/ruby-build.git'
+ user 'vagrant'
+end
+
+rbenv_ruby '2.4.1' do
+ user 'vagrant'
+end
+
+rbenv_global version do
+ user 'vagrant'
+end
diff --git a/test/fixtures/cookbooks/test/recipes/dokken.rb b/test/fixtures/cookbooks/test/recipes/dokken.rb
new file mode 100644
index 00000000..6adb4cdd
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/dokken.rb
@@ -0,0 +1,17 @@
+# Make sure Vagrant user is on the box. This should fix the dokken user install
+user 'vagrant'
+
+group 'vagrant' do
+ members 'vagrant'
+end
+
+directory '/home/vagrant' do
+ owner 'vagrant'
+ group 'vagrant'
+ not_if { platform?('windows') }
+end
+
+group 'rvm' do
+ members ['vagrant']
+ append true
+end
diff --git a/test/fixtures/cookbooks/test/recipes/gem.rb b/test/fixtures/cookbooks/test/recipes/gem.rb
new file mode 100644
index 00000000..b1e7b7f7
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/gem.rb
@@ -0,0 +1,51 @@
+# Make sure that Vagarant user is on the box for dokken
+include_recipe 'test::dokken'
+
+# System Install
+rbenv_system_install 'system'
+# Install several Rubies to a system wide location
+rbenv_ruby '2.4.1' do
+ verbose true
+end
+
+rbenv_ruby '2.7.1' do
+ verbose true
+end
+
+# Set System global version
+rbenv_global '2.4.1'
+
+rbenv_gem 'mail' do
+ version '2.6.5'
+ rbenv_version '2.7.1'
+end
+
+rbenv_gem 'mail' do
+ version '2.6.5'
+ rbenv_version '2.4.1'
+end
+
+rbenv_gem 'mail' do
+ version '2.6.5'
+ rbenv_version '2.4.1'
+ action :remove
+end
+
+# User Install
+rbenv_user_install 'vagrant'
+
+# Install a Ruby to a user directory
+rbenv_ruby '2.7.1' do
+ user 'vagrant'
+end
+
+# Set the vagrant global version
+rbenv_global '2.7.1' do
+ user 'vagrant'
+end
+
+rbenv_gem 'bundler' do
+ version '1.15.4'
+ user 'vagrant'
+ rbenv_version '2.7.1'
+end
diff --git a/test/fixtures/cookbooks/test/recipes/global.rb b/test/fixtures/cookbooks/test/recipes/global.rb
new file mode 100644
index 00000000..152a2c4d
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/global.rb
@@ -0,0 +1,14 @@
+global_version = '2.4.1'
+
+# Install Rbenv Globally
+rbenv_system_install 'system'
+
+rbenv_ruby global_version do
+ verbose true
+end
+
+# Make sure that Vagarant user is on the box for dokken
+include_recipe 'test::dokken'
+
+# Set that Ruby as the global Ruby
+rbenv_global global_version
diff --git a/test/fixtures/cookbooks/test/recipes/plugin.rb b/test/fixtures/cookbooks/test/recipes/plugin.rb
new file mode 100644
index 00000000..1bdb6fd0
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/plugin.rb
@@ -0,0 +1,28 @@
+version = '2.4.1'
+
+# Make sure that Vagarant user is on the box for dokken
+include_recipe 'test::dokken'
+
+rbenv_user_install 'vagrant'
+
+rbenv_system_install 'system'
+
+rbenv_ruby version do
+ install_ruby_build false
+ user 'vagrant'
+end
+
+rbenv_global version do
+ user 'vagrant'
+end
+
+rbenv_plugin 'ruby-build' do
+ git_url 'https://github.com/rbenv/ruby-build.git'
+ user 'vagrant'
+end
+
+# This should get installed to the system_install
+rbenv_plugin 'user-gems' do
+ git_url 'git@github.com:mislav/rbenv-user-gems.git'
+ git_ref 'v1.0.1'
+end
diff --git a/test/fixtures/cookbooks/test/recipes/rehash.rb b/test/fixtures/cookbooks/test/recipes/rehash.rb
new file mode 100644
index 00000000..e7596e3e
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/rehash.rb
@@ -0,0 +1 @@
+rbenv_rehash 'defaultness'
diff --git a/test/fixtures/cookbooks/test/recipes/ruby_uninstall.rb b/test/fixtures/cookbooks/test/recipes/ruby_uninstall.rb
new file mode 100644
index 00000000..c6f32216
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/ruby_uninstall.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+system_version = '2.5.1'
+
+# Make sure that Vagarant user is on the box for dokken
+include_recipe 'test::dokken'
+
+# System Install
+rbenv_system_install 'system'
+
+# Install system wide Ruby
+rbenv_ruby system_version
+
+# Set System global version
+rbenv_global system_version
+
+# Uninstall Ruby
+rbenv_ruby system_version do
+ rbenv_action 'uninstall'
+end
diff --git a/test/fixtures/cookbooks/test/recipes/script.rb b/test/fixtures/cookbooks/test/recipes/script.rb
new file mode 100644
index 00000000..67619d85
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/script.rb
@@ -0,0 +1,3 @@
+rbenv_script 'not-much' do
+ code 'rake nadda'
+end
diff --git a/test/fixtures/cookbooks/test/recipes/system_install.rb b/test/fixtures/cookbooks/test/recipes/system_install.rb
new file mode 100644
index 00000000..038b19b8
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/system_install.rb
@@ -0,0 +1,2 @@
+# Install Rbenv to the system path e.g. /usr/local/rvm
+rvm_system_install 'system'
diff --git a/test/fixtures/cookbooks/test/recipes/user_install.rb b/test/fixtures/cookbooks/test/recipes/user_install.rb
new file mode 100644
index 00000000..e2eac8f9
--- /dev/null
+++ b/test/fixtures/cookbooks/test/recipes/user_install.rb
@@ -0,0 +1,21 @@
+# Install rbenv and makes it avilable to the selected user
+version = '2.4.1'
+
+# Make sure that Vagarant user is on the box for dokken
+include_recipe 'test::dokken'
+
+# Keeps the rbenv install upto date
+rbenv_user_install 'vagrant'
+
+rbenv_plugin 'ruby-build' do
+ git_url 'https://github.com/rbenv/ruby-build.git'
+ user 'vagrant'
+end
+
+rbenv_ruby '2.4.1' do
+ user 'vagrant'
+end
+
+rbenv_global version do
+ user 'vagrant'
+end
diff --git a/test/integration/data_bags/users/virgil1.json b/test/integration/data_bags/users/virgil1.json
deleted file mode 100644
index 953ff298..00000000
--- a/test/integration/data_bags/users/virgil1.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "id": "virgil1"
-}
-
diff --git a/test/integration/data_bags/users/virgil2.json b/test/integration/data_bags/users/virgil2.json
deleted file mode 100644
index e7846289..00000000
--- a/test/integration/data_bags/users/virgil2.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "id": "virgil2"
-}
-
diff --git a/test/integration/data_bags/users/wigglebottom.json b/test/integration/data_bags/users/wigglebottom.json
deleted file mode 100644
index 6283782e..00000000
--- a/test/integration/data_bags/users/wigglebottom.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "id": "wigglebottom"
-}