Version information
This version is compatible with:
Start using this module
Add this module to your Puppetfile:
mod 'dmcnicks-rubies', '1.4.0'
Learn more about managing modules with a PuppetfileDocumentation
Rubies Puppet Module
Table of Contents
Overview
Installs and configures self-packaged versions of Ruby.
Module Description
This is a Puppet module that installs multiple self-packaged versions of Ruby onto nodes using the Puppet File Server and installs chruby to switch between Ruby versions.
The module also provides a custom package provider that allows gems to be installed into specific versions of Ruby.
Dependencies
- Requires configuration changes to the Puppet File Server.
- Requires self-packaged versions of Ruby to be made available.
Tested on
- Debian 7 (wheezy)
Setup
What the rubies module affects
- Downloads the chruby tarball into
/opt
. - Unpacks the chruby tarball into
/opt/chruby-<release>
. - Installs
chruby
. - Downloads multiple Ruby packages into
/opt
. - Installs the downloaded packages into
/opt/rubies
. - Deploys
/etc/profile.d/chruby.sh
to configurechruby
for all users.
Beginning with the rubies module
By default the module will install release 0.3.9
of chruby
:
include 'rubies'
To deploy rubies to the node you will have to specify package versions:
class { 'rubies':
versions => [ '1.9.3p194', '2.2.1' ]
}
You can set the default ruby version:
class { 'rubies':
versions => [ '1.9.3p194', '2.2.1' ],
default => '2.2.1'
}
The version of chruby
that is installed can be overriden:
class { 'rubies':
chruby_release => '0.3.9'
versions => [ '1.9.3p194', '2.2.1' ],
default => '2.2.1'
}
Installing gems
The rubies module provides a custom gem
type for installing gems into
specific version of ruby. The title of the type declaration should include
the name of the gem and the ruby version it should be installed into. For
example:
gem { "bundler in 2.2.1":
ensure => 'present',
}
gem { "unicorn in 2.2.1":
ensure => 'present'
}
Using a composite title means that the same gem can be installed in multiple versions of ruby without causing any name clashes:
gem { "bundler in 1.9.3p194":
ensure => 'present',
}
gem { "bundler in 2.2.0":
ensure => 'present',
}
gem { "bundler in 2.2.1":
ensure => 'present',
}
If you want to specify gems in modules that deploy applications you can
specify a for
clause to make the gem declaration more unique:
gem { "unicorn in 2.2.1 for myapp":
ensure => 'present'
}
gem { "unicorn in 2.2.1 for otherapp":
ensure => 'present'
}
The application names are ignored by the provider. In the case above, the
second hem would notice that unicorn
has been installed into Ruby 2.2.1 and
do nothing.
Configuring the Puppet File Server
Create a public
directory to be shared:
mkdir /srv/public
chown puppet:puppet /srv/public
Edit /etc/puppet/fileserver.conf
and append the following:
[public]
path /srv/public
allow *
Edit /etc/puppet/auth.conf
, locate the path /file
paragraph and add the
following above it:
path ~ ^/file_(metadata|content)/public/
auth yes
allow *
Restart the Puppet master:
service apache2 restart
Packaging versions of Ruby
On the Puppet server, download, unpack and install ruby-install
:
wget -O /opt/ruby-install-0.5.0.tar.gz https://github.com/postmodern/ruby-install/archive/v0.5.0.tar.gz
tar -xzC /opt -f /opt/ruby-install-0.5.0.tar.gz
make install -C /opt/ruby-install-0.5.0
Install fpm
:
apt-get install -y ruby-dev
gem install fpm --no-rdoc --no-ri
Build the version of Ruby you require using ruby-install
:
ruby-install ruby 2.2.2
Package the new version of Ruby with fpm
:
fpm -s dir -t deb -n rubies-ruby-2.2.2 \
-C /opt/rubies/ruby-2.2.2 --prefix /opt/rubies/ruby-2.2.2 \
--description "SGP self-packaged Ruby v2.2.2" \
-p /srv/public/rubies-ruby-2.2.2.deb \
bin include lib share
Update your Puppet manifests to use the new version of Ruby:
class { 'rubies':
versions => [ '1.9.3p194', '2.2.1', '2.2.2' ],
default => '2.2.2'
}
Usage
The rubies
class
The module's primary class.
Parameters
chruby_release
(Optional) The release of chruby to install (defaults to 0.3.9).
versions
(Optional) An array of ruby packages to install (defaults to empty).
default
(Optional) The default version of Ruby available to users (defaults to system).
Limitations
There may be incompatibilities with other OS versions, packages and configurations.
Development
I am happy to receive pull requests.