Puppet Class: rvm::system
- Inherits:
- rvm::params
- Defined in:
- manifests/system.pp
Overview
Install the RVM system
2 3 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 |
# File 'manifests/system.pp', line 2
class rvm::system (
Optional[String[1]] $version = undef,
Optional[String[1]] $install_from = undef,
Optional[String[1]] $proxy_url = undef,
Optional[String[1]] $no_proxy = undef,
Stdlib::Absolutepath $home = $facts['root_home'],
Array[Hash[String[1], String[1]]] $signing_keys = $rvm::params::signing_keys,
) inherits rvm::params {
$actual_version = $version ? {
undef => 'latest',
'present' => 'latest',
default => $version,
}
$http_proxy_environment = $proxy_url ? {
undef => [],
default => ["http_proxy=${proxy_url}", "https_proxy=${proxy_url}"]
}
$no_proxy_environment = $no_proxy ? {
undef => [],
default => ["no_proxy=${no_proxy}"]
}
$proxy_environment = concat($http_proxy_environment, $no_proxy_environment)
$environment = concat($proxy_environment, ["HOME=${home}"])
if $signing_keys {
include gnupg
# https keys are downloaded with wget
ensure_packages(['wget'])
$signing_keys.each |Hash[String[1], String[1]] $key| {
gnupg_key { $key['id']:
ensure => 'present',
user => 'root',
key_id => $key['id'],
key_source => $key['source'],
key_type => public,
before => Exec['system-rvm'],
require => Class['gnupg'],
}
}
}
if $install_from {
file { '/tmp/rvm':
ensure => directory,
}
exec { 'unpack-rvm':
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
command => "tar --strip-components=1 -xzf ${install_from}",
cwd => '/tmp/rvm',
}
exec { 'system-rvm':
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
command => './install --auto-dotfiles',
cwd => '/tmp/rvm',
creates => '/usr/local/rvm/bin/rvm',
environment => $environment,
}
}
else {
ensure_packages(['curl'])
exec { 'system-rvm':
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
command => "curl -fsSL https://get.rvm.io | bash -s -- --version ${actual_version}",
creates => '/usr/local/rvm/bin/rvm',
environment => $environment,
require => Package['curl'],
}
}
# the fact won't work until rvm is installed before puppet starts
if $facts['rvm_version'] and !empty($facts['rvm_version']) {
if ($version != undef) and ($version != present) and ($version != $facts['rvm_version']) {
$signing_keys.each |Hash[String[1], String[1]] $key| {
Gnupg_key[$key['id']] -> Exec['system-rvm-get']
}
# Update the rvm installation to the version specified
notify { 'rvm-get_version':
message => "RVM updating from version ${facts['rvm_version']} to ${version}",
}
-> exec { 'system-rvm-get':
path => '/usr/local/rvm/bin:/usr/bin:/usr/sbin:/bin',
command => "rvm get ${version}",
before => Exec['system-rvm'], # so it doesn't run after being installed the first time
environment => $environment,
}
}
}
}
|