forked from blt04/puppet-rvm
/
system.pp
47 lines (42 loc) · 1.54 KB
/
system.pp
1
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
class rvm::system(
$version=undef,
$proxy_url=undef) {
$actual_version = $version ? {
undef => 'latest',
'present' => 'latest',
default => $version,
}
# curl needs to be installed
if ! defined(Package['curl']) {
case $::kernel {
Linux: {
ensure_packages(['curl'])
Package['curl'] -> Exec['system-rvm']
}
default: {}
}
}
exec { 'system-rvm':
path => '/usr/bin:/usr/sbin:/bin',
command => "/usr/bin/curl -fsSL https://get.rvm.io | bash -s -- --version ${actual_version}",
creates => '/usr/local/rvm/bin/rvm',
environment => $proxy_url ? { undef => undef, default => [ "http_proxy=${proxy_url}" , "https_proxy=${proxy_url}" ]},
}
# the fact won't work until rvm is installed before puppet starts
if "${::rvm_version}" != "" {
notice("RVM version ${::rvm_version}")
if ($version != undef) and ($version != present) and ($version != $::rvm_version) {
# Update the rvm installation to the version specified
notify { 'rvm-get_version':
message => "RVM updating to version ${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 => $proxy_url ? { undef => undef, default => [ "http_proxy=${proxy_url}" , "https_proxy=${proxy_url}" ]},
require => Notify['rvm-get_version'],
}
}
}
}