Created
May 5, 2011 16:35
-
-
Save mudge/957375 to your computer and use it in GitHub Desktop.
Puppet class for a CentOS/RedHat server with RVM installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rvm_server/manifests/init.pp | |
class rvm_server($version='latest') { | |
# Dependencies for RVM and Ruby. | |
package { 'rvm-dependencies': | |
ensure => installed, | |
name => ['bash', 'gawk', 'sed', 'grep', 'which', 'coreutils', 'tar', | |
'curl', 'gzip', 'bzip2', 'gcc-c++', 'autoconf', 'patch', | |
'readline', 'readline-devel', 'zlib', 'zlib-devel', | |
'libyaml-devel', 'libffi-devel', 'openssl-devel', | |
'glibc-headers', 'glibc-devel', 'libxml2', 'libxml2-devel', | |
'libxslt', 'libxslt-devel', 'curl-devel', 'mysql-devel'], | |
} | |
# Use RVM's installer to install our desired version. This will keep the installer | |
# around so we run it from /root | |
exec { 'rvm-install': | |
cwd => '/root', | |
command => "curl -s https://rvm.beginrescueend.com/install/rvm -o rvm-installer ; chmod +x rvm-installer ; ./rvm-installer --version ${version}", | |
unless => "grep ${version} /usr/local/rvm/VERSION", | |
path => '/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin', | |
require => Package['rvm-dependencies'], | |
} | |
file { '/usr/local/rvm/gemsets/global.gems': | |
ensure => present, | |
content => "rake\nbundler\n", | |
require => Exec['rvm-install'], | |
} | |
file { '/etc/gemrc': | |
ensure => present, | |
content => 'install: --no-rdoc --no-ri\nupdate: --no-rdoc --no-ri\n', | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A sample manifest using the RVM module. | |
include rvm_server | |
rvm_server::ruby { 'ruby19': | |
version => 'ruby-1.9.2-p180', | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rvm_server/manifests/ruby.pp | |
define rvm_server::ruby($version) { | |
exec { "rvm-ruby-install-${name}": | |
# Puppet seems to execute binaries directly without using a shell, so make sure | |
# to use bash for sourcing RVM's script before installing Ruby. | |
command => "bash -c 'source /usr/local/rvm/scripts/rvm ; rvm install ${version}'", | |
creates => "/usr/local/rvm/rubies/${version}", | |
# Be lenient as this needs to download, compile and install Ruby. | |
timeout => 1800, | |
path => '/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin', | |
# Depend on the global gemset being defined so that Ruby is installed | |
# with our default gems. | |
require => [File['/usr/local/rvm/gemsets/global.gems'], File['/etc/gemrc']], | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment