Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ Install a couple of Rubies
single_user_rvm::install_ruby { 'ruby-1.9.3-p392': user => 'username' }
single_user_rvm::install_ruby { 'ruby-2.0.0-p247': user => 'username' }

Set the default ruby
--------------------

single_user_rvm::default {'ruby-1.9.3': user => 'username' }

ruby-1.9.3 is a grep match on the output of rvm current

More info in [install_ruby.pp](manifests/install_ruby.pp)

License
Expand Down
47 changes: 47 additions & 0 deletions manifests/default.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# == Define: single_user_rvm::default
#
# Sets the default RVM ruby
#
# # === Parameters
#
# # [*ruby_string*]
# Ruby version to install, be sure to use the full Ruby string as failing to do so will break the mechanism that
# detects if the required ruby is already installed. Defaults to the value of the title string.
# Should match a ruby installed by single_user_rvm::install_ruby
#
# [*user*]
# The user for which this Ruby will be installed. Defaults to 'rvm'.
#
# === Examples
#
# Set Ruby 2.0.0 p247 as default for user 'dude':
#
# single_user_rvm::default { 'ruby-2.0.0-p247':
# user => 'dude',
# }
#
define single_user_rvm::default (
$user ='rvm') {

if $home {
$homedir = $home
} else {
$homedir = "/home/${user}"
}


$command = "rvm use --default ${title}"
$check_command = "rvm current"

exec { "su -l ${user} -c '${command}'":
path => "/usr/bin:/usr/sbin:/bin:~/.rvm/bin",
provider => shell,
logoutput => false,
cwd => "/home/${user}",
require => Single_user_rvm::Install[$user],
unless => "su -l ${user} -c '${check_command}' | grep ${title}"
}


}