Packaging ruby and puppet together to avoid using rvm

People at my place don’t trust rvm.

Personally found it easy to switch between different ruby versions to test things out.

Had to find a way to avoid using rvm and also not rely on the system wide ruby in the production machines.

Decided to build the newest ruby and install the puppet gem using the just installed ruby.

After ./configure ing with a –prefix flag to keep the install isolated,  I had to override the default PATH variable to point to the ruby we just built and installed.

export PATH=${PUPPET_RUBY_DIR}/bin/:$PATH
export GEM_HOME=${PUPPET_RUBY_DIR}/lib/ruby/gems/1.9.1/gems/
export GEM_PATH=${PUPPET_RUBY_DIR}/lib/ruby/gems/1.9.1/gems/

Now Gem install the desired puppet and packaged the whole directory with fpm or your favorite rpmbuild tool.

(I’ll make this rpm available somewhere for anyone interested).

Installing this rpm gives me isolated ruby and puppet that doesn’t rely on the system ruby or the rvm.

My puppet client has this startup script,  setting all the ruby path and gem path

#!/bin/bash
#set -x
PUPPET_RUBY_DIR="/usr/local/puppetandruby"
#
# Usage
#
usage(){
 echo "Usage: $0 master_server extra_opts " 
 echo "Extra_opts --waitforcert 20 -v -d --environment staging --trace --logdest /var/log/puppet/puppetd.log " 
 exit 1
}
[[ $1 == "-h" ]] && usage 
[[ $1 == "-help" ]] && usage
#
# Need params
#
[[ $# -lt 1 ]] && usage

PUPPET_MSTR_SERVER=$1
shift 
EXTRA_OPTS=$@

# Let the path find puppet's ruby first 
export PATH=${PUPPET_RUBY_DIR}/bin/:$PATH
# Set the GEM home and path for the puppet ruby
export GEM_HOME=${PUPPET_RUBY_DIR}/lib/ruby/gems/1.9.1/gems/
export GEM_PATH=${PUPPET_RUBY_DIR}/lib/ruby/gems/1.9.1/gems/

PUPPETD=${PUPPET_RUBY_DIR}/lib/ruby/gems/1.9.1/gems/bin/puppetd

${PUPPET_RUBY_DIR}/bin/ruby ${PUPPETD} --server ${PUPPET_MSTR_SERVER} ${EXTRA_OPTS}

Have not encountered any obvious failing with this approach,  now to test these in a completely fresh system to make sure I’m not missing anything.

Couldn’t shake off the feeling that I’m missing something though.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: