rvm
Version information
This version is compatible with:
- Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
- Puppet >= 7.0.0 < 8.0.0
- , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'puppet-rvm', '3.0.0'
Learn more about managing modules with a PuppetfileDocumentation
Puppet Module for Ruby Version Manager (RVM)
This module handles installing system RVM (also known as multi-user installation as root) and using it to install rubies and gems. Support for installing and configuring passenger is also included.
We are actively using this module. It works well, but does have some issues you
should be aware of. Due to the way puppet works, certain resources
(rvm_sytem_ruby, rvm_gem and rvm_gemset) may generate errors until RVM is
installed. You may want to use run stages to install RVM before the rest
of your configuration runs. However, if you run puppet using the --noop
parameter, you may see Could not find a default provider errors. See the
Troubleshooting section for more information.
Please read the troubleshooting section below before opening an issue.
Add Puppet Module
Before you begin, you must add the RVM module to your Puppet installation. This can be done with:
$ puppet module install puppet/rvm
You may now continue configuring RVM resources.
Install RVM with Puppet
class { 'rvm': }
This will install RVM into /usr/local/rvm
.
To use RVM without sudo, users need to be added to the rvm
group. This can be easily done with:
rvm::system_user { bturner: ; jdoe: ; jsmith: ; }
If GPG is installed, installing RVM requires the RVM GPG key.
This module will install the key if gpg
is already installed or being installed with the
golja-gnupg
module.
If you don't want this module to manage any signing keys, set the signing_keys
parameter to []
class { 'rvm': signing_keys => [] }
Installing Ruby
You can tell RVM to install one or more Ruby versions with:
rvm_system_ruby {
'ruby-1.9':
ensure => 'present',
default_use => true,
build_opts => ['--binary'];
'ruby-2.0':
ensure => 'present',
default_use => false;
}
You should use the full version number. While the shorthand version may work (e.g. '1.9.2'), the provider will be unable to detect if the correct version is installed.
If rvm fails to install binary rubies you can increase curl's timeout with the rvm_max_time_flag
in ~/.rvmrc
with a fully qualified path to the home directory.
# ensure rvm doesn't timeout finding binary rubies
# the umask line is the default content when installing rvm if file does not exist
file { '/home/user/rvmrc':
content => 'umask u=rwx,g=rwx,o=rx
export rvm_max_time_flag=20',
mode => '0664',
before => Class['rvm'],
}
Or, to configure /etc/rvmrc
you can use use Class['rvm::rvmrc]
class{ 'rvm::rvmrc':
max_time_flag => 20,
before => Class['rvm'],
}
Installing JRuby from sources
JRuby has some extra requirements, java, maven and ant that you can install using puppetlabs/java, maestrodev/ant and maestrodev/maven modules.
class { 'java': } ->
class { 'ant': } ->
class { 'maven::maven': } ->
rvm_system_ruby { 'jruby-1.7.6':
ensure => 'present',
default_use => false;
}
Creating Gemsets
Create a gemset with:
rvm_gemset {
'ruby-1.9.3-p448@myproject':
ensure => present,
require => Rvm_system_ruby['ruby-1.9.3-p448'];
}
Installing Gems
Install a gem with:
rvm_gem {
'ruby-1.9.3-p448@myproject/bundler':
ensure => '1.0.21',
require => Rvm_gemset['ruby-1.9.3-p448@myproject'];
}
The name of the gem should be <ruby-version>[@<gemset>]/<gemname>
. For example, you can install bundler for ruby-1.9.2 using ruby-1.9.3-p448/bundler
. You could install rails in your project's gemset with: ruby-1.9.3-p448@myproject/rails
.
Alternatively, you can use this more verbose syntax:
rvm_gem {
'bundler':
name => 'bundler',
ruby_version => 'ruby-1.9.3-p448',
ensure => latest,
require => Rvm_system_ruby['ruby-1.9.3-p448'];
}
Creating Aliases
To create an RVM alias, you can use:
rvm_alias {
'myproject':
target_ruby => 'ruby-1.9.3-p448@myproject',
ensure => present,
require => Rvm_gemset['ruby-1.9.3-p448@myproject'];
}
Creating Wrappers
To create an RVM wrapper, you can use:
rvm_wrapper {
'god':
target_ruby => 'ruby-1.9.3-p448',
prefix => 'bootup',
ensure => present,
require => Rvm_system_ruby['ruby-1.9.3-p448'];
}
Installing Passenger
NOTE: You must install the puppetlabs/apache module by yourself. It is not included as a dependency to this module to avoid installing it when is not needed most times.
Install passenger using the puppetlabs/apache module, and using:
class { 'apache': }
class { 'rvm::passenger::apache':
version => '3.0.11',
ruby_version => 'ruby-1.9.3-p448',
mininstances => 3,
maxinstancesperapp => 0,
maxpoolsize => 30,
spawnmethod => 'smart-lv2',
}
Using Hiera
You can configure the ruby versions to be installed and the system users from hiera
rvm::system_rubies:
'ruby-1.9':
default_use: true
'ruby-2.0': {}
'jruby-1.7': {}
rvm::system_users:
- john
- doe
rvm::rvm_gems:
'bundler':
name: 'bundler'
ruby_version: 'ruby-1.9'
ensure: latest
Building the module
Testing is done with rspec, Beaker-rspec, Beaker)
To test and build the module
bundle install
# run specs
rake
# run Beaker system tests with vagrant vms
rake beaker
# to use other vm from the list spec/acceptance/nodesets and not destroy the vm after the tests
BEAKER_destroy=no BEAKER_set=centos-64-x64 bundle exec rake beaker
# Release the Puppet module to the Forge, doing a clean, build, tag, push, bump_commit and git push
rake module:release
Troubleshooting / FAQ
An error "Could not find a default provider for rvm_system_ruby" is displayed when running Puppet with --noop
This means that puppet cannot find the /usr/local/rvm/bin/rvm
command
(probably because RVM isn't installed yet). Currently, Puppet does not support
making a provider suitable using another resource (late-binding). You may want
to use run stages to install RVM before the rest of the
configuration runs. When running in noop mode, RVM is not actually installed
causing rvm_system_ruby, rvm_gem and rvm_gemset resources to generate this
error. You can avoid this error by surrounding your rvm configuration in an if
block:
if $rvm_installed == "true" {
rvm_system_ruby ...
}
Do not surround include rvm
in the if block, as this is used to install RVM.
NOTE: $rvm_installed is evaluated at the beginning of each puppet run. If you use this in your manifests, you will need to run puppet twice to fully configure RVM.
Some packages/libraries I don't want or need are installed (e.g. build-essential, libc6-dev, libxml2-dev).
RVM works by compiling Ruby from source. This means you must have all the libraries and binaries required to compile Ruby installed on your system, which is handled by rvm autolibs in newer versions of RVM.
It doesn't work on my operating system.
Check the rspec-system tests as described above to test in a specific OS If that doesn't work feel free to send a pull request ;)
Why didn't you just add an RVM provider for the existing package type?
The puppet package type seems like an obvious place for the RVM provider. It would be nice if the syntax for installing Ruby with RVM looked like:
# NOTE: This does not work
package {'ruby':
provider => 'rvm',
ensure => '1.9.2-p290';
}
While this may be possible, it becomes harder to manage multiple Ruby versions and nearly impossible to install gems for a specific Ruby version. For this reason, I decided it was best to create a completely new set of types for RVM.
Changelog
All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module.
v3.0.0 (2024-01-09)
Breaking changes:
- Drop OracleLinux support #204 (ekohl)
- Drop Puppet 6 support #197 (bastelfreak)
Implemented enhancements:
- puppetlabs/stdlib: Allow 9.x #199 (bastelfreak)
- make gnupg class/wget package optional #193 (bastelfreak)
Fixed bugs:
- Fix broken logic for gpg keys #192 (bastelfreak)
- Deal with -next part in RVM versions #191 (jplindquist)
Merged pull requests:
v2.0.0 (2022-07-07)
Breaking changes:
- Add support for Puppet 7, EL8 & Debian 11; drop Debian 9 #184 (ekohl)
- Add data types and other minor cleanups #182 (ekohl)
- Rename gnupg_key_id parameter to signing_keys #178 (saz)
- Drop Solaris support #177 (bastelfreak)
- Drop Windows support #176 (bastelfreak)
- Drop AIX support #175 (bastelfreak)
- Update supported Ubuntu versions to 18.04 & 20.04 #169 (bastelfreak)
- Update Debian to support versions 9 & 10 #168 (bastelfreak)
- Drop EOL EL4, EL5 and EL6 #167 (bastelfreak)
- Drop EoL Puppet 5 #166 (bastelfreak)
- Remove
rvm::gpg
class #149 (alexjfisher)
Implemented enhancements:
- Properly ensure curl is present when needed #181 (ekohl)
- puppetlabs/stdlib: Allow 7.x/8.x #170 (bastelfreak)
- Allow rvm to mount a Ruby #110 (paulccarey)
Fixed bugs:
- Support environment isolation by removing lambdas from title patterns #163 (joshperry)
- update GPG key #159 (mmoll)
- Update deprecated install options, and strip default string from gem output #142 (jplindquist)
- Avoid warn with puppet4 #137 (PascalBourdier)
- Fix autolib_mode parameter references #123 (walkamongus)
Closed issues:
- OptionParser::InvalidOption ERROR when using --no-rdoc (this is not a warning) #146
- Update rvm signature key #145
Merged pull requests:
- Clean up tests of deprecated styles #180 (ekohl)
- puppet-lint: fix top_scope_facts warnings #172 (bastelfreak)
- Various Rubocop and lint fixes #164 (bastelfreak)
- Require puppet-epel over stahnma-epel in acceptance test #161 (dhoppe)
- Rubocop: Fix Lint/HandleExceptions #157 (alexjfisher)
- Rubocop: Fix RSpec/InstanceVariable #156 (alexjfisher)
- Rubocop: Fix Lint/AssignmentInCondition #155 (alexjfisher)
- Rubocop: Fix Style/GuardClause #154 (alexjfisher)
- Rubocop Autofixes #153 (alexjfisher)
- Fix puppet-lint errors and get tests running #152 (alexjfisher)
- Fix metadata.json lint warnings #151 (alexjfisher)
- Add dependencies to
.fixtures.yml
#150 (alexjfisher) - Convert rvm_system_ruby autolib_mode to parameter #122 (walkamongus)
v1.13.1 (2016-03-01)
Merged pull requests:
v1.13.0 (2016-03-01)
Closed issues:
- RVM tries, by default, to create a file /etc/rvmrc on Windows. #102
- Key D39DC0E3 does not exist on hkp://keys.gnupg.net #100
ensure => latest
results in resource change on every run #57
Merged pull requests:
- Fix idempotency error when using latest. #115 (eesprit)
- Include ruby- prefix in hiera example. #109 (rubys)
- System user and group #104 (stintel)
- -- Added a smartparam to toggle managing the rvmrc based on osfamily #103 (madelaney)
- fix 'Undefined variable "::rvm_version"' #99 (jangrewe)
- added support for freebsd and tests for freebsd/darwin #98 (tosmi)
v1.12.1 (2015-07-08)
Closed issues:
- rvm first install doesn't work because RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found #94
- Suggest using the forge approved module for gpg #86
- how to install rvm and ruby and gems under single user? #84
- rvm no available for user #72
- Can't install Rubinius #61
- Could not autoload rvm_system_ruby #60
Merged pull requests:
v1.12.0 (2015-05-16)
Closed issues:
Merged pull requests:
v1.11.0 (2015-03-27)
Merged pull requests:
v1.10.2 (2015-03-09)
v1.10.1 (2015-02-20)
Closed issues:
- Puppet RVM looks for presence of gpg2, but RVM installer is agostic #82
- CentOS 7 dependencies should be libcurl-devel not curl-devel #80
Merged pull requests:
v1.10.0 (2015-02-05)
Closed issues:
- Changes for gpg ignore Darwin (OSX) support #76
Merged pull requests:
v1.9.1 (2015-01-29)
Merged pull requests:
- allow override to not install mod_passenger if just installing the gem #75 (eefahy)
- Name check should be exact, not globbed #74 (scurvy)
v1.9.0 (2015-01-16)
Closed issues:
- passenger_mod.so missing? #54
Merged pull requests:
v1.8.1 (2014-12-19)
Closed issues:
- Concat() requires an array - but it has one #71
v1.8.0 (2014-12-15)
v1.7.1 (2014-11-25)
Closed issues:
- Push 1.7.0 to Forge #66
v1.7.0 (2014-11-20)
Closed issues:
- Gem not installing correctly #62
v1.6.6 (2014-09-15)
v1.6.5 (2014-09-12)
Closed issues:
- run gem installed with rvm_gem? #56
- Invalid resource type rvm_wrapper #55
- instructions to use
file{'/etc/rvmrc'}
fail as duplicate #51
Merged pull requests:
v1.6.4 (2014-08-19)
Merged pull requests:
v1.6.3 (2014-08-18)
Merged pull requests:
- Add silence_path_mismatch_check_flag to rvm::rvmrc #53 (mczepiel)
- consider not using ensure_resource in system_user.pp #50 (eefahy)
v1.6.2 (2014-07-29)
Merged pull requests:
- Use OS X's directory service tools to manage adding user to rvm group #48 (paulmakepeace)
v1.6.1 (2014-07-23)
v1.6.0 (2014-07-22)
Closed issues:
- How to: Not use group=rvm #46
- rvm::passenger::apache not loading correct mod_passenger.so module on Debian #18
Merged pull requests:
v1.5.9 (2014-06-24)
Closed issues:
Merged pull requests:
- Fix RVM version logging #44 (jbussdieker)
v1.5.8 (2014-06-09)
Closed issues:
- documentation references puppet 2.x, module requires puppet 3 #35
Merged pull requests:
v1.5.7 (2014-05-27)
v1.5.6 (2014-05-13)
Closed issues:
- 1.5.6 is not on the forge #38
Merged pull requests:
v1.5.5 (2014-04-30)
Closed issues:
- RVM Fails due to some certificate #36
- Puppet + puppet-rvm + bundler defaults to system Ruby, not RVM default #33
- mod_passenger is installed with yum #28
v1.5.4 (2014-04-04)
Closed issues:
- spec/acceptance instructions in README are out of date #31
Merged pull requests:
v1.5.3 (2014-03-31)
v1.5.2 (2014-03-19)
Closed issues:
- Fail to install necessary package "curl" #24
v1.5.1 (2014-03-15)
Closed issues:
- Why does puppet-rvm depend on puppet-apache? #27
- Issue installing system wide and rails app #26
- Installation Help #19
- encountering general issues related to running puppet as root #16
v1.5.0 (2014-03-06)
v1.4.4 (2014-03-05)
Closed issues:
- RVM not in PATH after installation #25
v1.4.3 (2014-03-04)
v1.4.2 (2014-02-24)
Closed issues:
- Module assumes there's a rvm group #20
Merged pull requests:
v1.4.1 (2014-01-31)
v1.4.0 (2014-01-27)
v1.3.1 (2014-01-22)
Closed issues:
- rvm fails when /tmp is mounted with noexec flag #9
v1.3.0 (2014-01-14)
Closed issues:
v1.2.0 (2013-11-06)
v1.1.12 (2013-10-27)
Closed issues:
- RVM version change fails due to recent commit #10
Merged pull requests:
v1.1.11 (2013-10-15)
v1.1.10 (2013-10-15)
v1.1.9 (2013-10-11)
v1.1.8 (2013-09-05)
v1.1.7 (2013-08-28)
v1.1.6 (2013-08-28)
Closed issues:
- Install Stage breaking entire puppet run due to missing dependencies #7
Merged pull requests:
v1.1.5 (2013-07-23)
v1.1.4 (2013-06-21)
v1.1.3 (2013-06-19)
v1.1.2 (2013-06-05)
v1.1.1 (2013-05-30)
v1.1.0 (2013-05-29)
Closed issues:
- Invalid option when installing gems #6
- Installing RVM breaks puppet on target system #5
- Ruby 2.0.0-p0 CentOS 6 has additional dependencies. #4
- using rvm to different location #2
v1.0.0 (2013-01-30)
* This Changelog was automatically generated by github_changelog_generator
Dependencies
- puppetlabs/stdlib (>= 4.13.0 < 10.0.0)
- golja/gnupg (>= 1.2.0 < 2.0.0)
BSD 3-Clause License Copyright (c) 2012-2013, MaestroDev, Brandon Turner Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.