Defined Type: rbenv::compile
- Defined in:
- manifests/compile.pp
Overview
The following part compiles and installs the chosen ruby version, using the “ruby-build” rbenv plugin.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'manifests/compile.pp', line 4
define rbenv::compile(
$user,
$ruby = $title,
$group = $user,
$home = '',
$root = '',
$source = '',
$global = false,
$configure_opts = '--disable-install-doc',
) {
# Workaround http://projects.puppetlabs.com/issues/9848
$home_path = $home ? { '' => "/home/${user}", default => $home }
$root_path = $root ? { '' => "${home_path}/.rbenv", default => $root }
$bin = "${root_path}/bin"
$shims = "${root_path}/shims"
$versions = "${root_path}/versions"
$global_path = "${root_path}/version"
$path = [ $shims, $bin, '/bin', '/usr/bin' ]
if ! defined( Class['rbenv::dependencies'] ) {
require rbenv::dependencies
}
# If no ruby-build has been specified and the default resource hasn't been
# parsed
$custom_or_default = Rbenv::Plugin["rbenv::plugin::rubybuild::${user}"]
$default = Rbenv::Plugin::Rubybuild["rbenv::rubybuild::${user}"]
if ! defined($custom_or_default) and ! defined($default) {
debug("No ruby-build found for ${user}, going to add the default one")
rbenv::plugin::rubybuild { "rbenv::rubybuild::${user}":
user => $user,
group => $group,
home => $home,
root => $root
}
}
if $source {
rbenv::definition { "rbenv::definition ${user} ${ruby}":
user => $user,
group => $group,
source => $source,
ruby => $ruby,
home => $home,
root => $root,
require => Rbenv::Plugin["rbenv::plugin::rubybuild::${user}"],
before => Exec["rbenv::compile ${user} ${ruby}"]
}
}
# Set Timeout to disabled cause we need a lot of time to compile.
# Use HOME variable and define PATH correctly.
exec { "rbenv::compile ${user} ${ruby}":
command => "rbenv install ${ruby} && touch ${root_path}/.rehash",
timeout => 0,
user => $user,
group => $group,
cwd => $home_path,
environment => [ "HOME=${home_path}", "CONFIGURE_OPTS=${configure_opts}" ],
creates => "${versions}/${ruby}",
path => $path,
require => Rbenv::Plugin["rbenv::plugin::rubybuild::${user}"],
before => Exec["rbenv::rehash ${user} ${ruby}"],
}
exec { "rbenv::rehash ${user} ${ruby}":
command => "rbenv rehash && rm -f ${root_path}/.rehash",
user => $user,
group => $group,
cwd => $home_path,
onlyif => "[ -e '${root_path}/.rehash' ]",
environment => [ "HOME=${home_path}" ],
path => $path,
}
# Install bundler
#
rbenv::gem {"rbenv::bundler ${user} ${ruby}":
user => $user,
ruby => $ruby,
gem => 'bundler',
home => $home_path,
root => $root_path,
}
# Set default global ruby version for rbenv, if requested
#
if $global {
file { "rbenv::global ${user}":
path => $global_path,
content => "$ruby\n",
owner => $user,
group => $group,
require => Exec["rbenv::compile ${user} ${ruby}"]
}
}
}
|