RVM + Chef Solo

by riverdale
13 deployments · 5 still active · last rev. 8 years ago

Almost the same as StackScript 1133, which configures a chef client on top of rvm. This script configures for chef solo. The expectation is that cookbooks and roles will be copied to /tmp/chef, and then chef-solo will be executed remotely over ssh.

UPDATE: rvm system-wide install fixed at 1.3.0, see http://stackoverflow.com/questions/5421800/rvm-system-wide-install-script-url-broken-what-is-replacement

Compatible with: No distros currently supported

# <udf name="hostname" label="Hostname">
# <udf name="default_ruby_interpreter" label="Default Ruby Interpreter"
#   oneOf="ruby-1.8.6,ruby-1.8.7,ruby-1.9.1,ruby-1.9.2,ruby-head" 
#   default="ruby-1.9.2">


echo "Setting locales (en_US.UTF-8)" >> $logfile
aptitude -y update
aptitude -y install locales
# Set locales to en_US.UTF-8
localedev -i en_US -c -f UTF-8 en_US.UTF-8

echo "Upgrading packages" >> $logfile
aptitude -y upgrade

echo "Setting hostname to {$HOSTNAME}" >> $logfile
echo ${HOSTNAME} > /etc/hostname
hostname -F /etc/hostname

echo "Installing RVM and Ruby dependencies" >> $logfile
apt-get -y install curl git-core bzip2 build-essential zlib1g-dev libssl-dev

echo "Installing RVM system-wide" >> $logfile
bash -c "bash <( curl -L https://github.com/wayneeseguin/rvm/raw/1.3.0/contrib/install-system-wide ) --version '1.3.0'"
cat >> /etc/profile <<'EOF'
# Load RVM if it is installed,
#  first try to load  user install
#  then try to load root install, if user install is not there.
if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
  . "$HOME/.rvm/scripts/rvm"
elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then
  . "/usr/local/rvm/scripts/rvm"

source /etc/profile

echo "Installing Ruby interpreter (${DEFAULT_RUBY_INTERPRETER})" >> $logfile
rvm use ${DEFAULT_RUBY_INTERPRETER} --default

echo "Installing Chef" >> $logfile
gem install chef

echo "Configuring Chef solo" >> $logfile
mkdir /etc/chef
cat >> /etc/chef/solo.rb <<EOF
file_cache_path "/tmp/chef"
cookbook_path "/tmp/chef/cookbooks"
role_path "/tmp/chef/roles"
log_level :info

echo "Script complete" >> $logfile