LEFT | RIGHT |
1 # == Class: ruby | 1 # == Class: ruby |
2 # | 2 # |
3 # Perform a custom Ruby installation based on the ruby-install script, | 3 # Perform a custom Ruby installation based on the ruby-install script, |
4 # using /usr/local as installation prefix. | 4 # using /usr/local as installation prefix. |
5 # | 5 # |
6 # === Parameters: | 6 # === Parameters: |
7 # | 7 # |
8 # [*version*] | 8 # [*version*] |
9 # The Ruby version to clone and build. | 9 # The Ruby version to build and install. |
| 10 # |
| 11 # [*logoutput*] |
| 12 # Whether and when to log the output of Exec resources; see |
| 13 # https://docs.puppetlabs.com/references/latest/type.html#exec-attribute-logou
tput |
10 # | 14 # |
11 # === Examples: | 15 # === Examples: |
12 # | 16 # |
13 # class {'ruby': | 17 # class {'ruby': |
14 # version => '2.2.0', | 18 # version => '2.2.0', |
| 19 # logoutput => true, |
15 # } | 20 # } |
16 # | 21 # |
17 class ruby( | 22 class ruby( |
18 $version = '2.1.5', | 23 $version = '2.1.5', |
| 24 $logoutput = 'on_failure', |
19 ) { | 25 ) { |
20 | 26 |
21 $ruby_install_source_url = 'https://github.com/postmodern/ruby-install.git' | 27 $install_src_url = 'https://github.com/postmodern/ruby-install.git' |
22 $ruby_install_source_dir = "/root/ruby-install" | 28 $install_src_dir = '/root/ruby-install' |
23 | 29 $install_command = "$install_src_dir/bin/ruby-install" |
24 Package { | |
25 ensure => 'installed', | |
26 } | |
27 | 30 |
28 Exec { | 31 Exec { |
29 logoutput => true, | 32 logoutput => true, |
30 path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | 33 path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', |
31 } | 34 } |
32 | 35 |
33 if !defined(Package['git']) { | 36 if !defined(Package['git']) { |
34 package {'git': } | 37 |
| 38 package {'git': |
| 39 ensure => 'installed', |
| 40 } |
35 } | 41 } |
36 | 42 |
37 exec {'ruby-clone-ruby-install': | 43 exec {'ruby-clone-ruby-install': |
38 command => shellquote('git', 'clone', $ruby_install_source_url, $ruby_instal
l_source_dir), | 44 command => shellquote('git', 'clone', $install_src_url, $install_src_dir), |
39 creates => $ruby_install_source_dir, | 45 creates => $install_src_dir, |
| 46 logoutput => $logoutput, |
| 47 require => Package['git'], |
40 } | 48 } |
41 -> | 49 -> |
42 exec {'ruby-execute-ruby-install': | 50 exec {'ruby-execute-ruby-install': |
43 command => shellquote("$ruby_install_source_dir/bin/ruby-install", '--system
', 'ruby', $ruby_version), | 51 command => shellquote($install_command, '--system', 'ruby', $version), |
44 creates => "/usr/local/bin/ruby", | 52 creates => '/usr/local/bin/ruby', |
| 53 logoutput => $logoutput, |
45 } | 54 } |
46 | |
47 Exec['ruby-clone-ruby-install'] <- Package['git'] | |
48 } | 55 } |
LEFT | RIGHT |