Skip to content

Instantly share code, notes, and snippets.

@mariusbutuc
Forked from ryanb/chef_solo_bootstrap.sh
Last active December 14, 2015 05:58
Show Gist options
  • Save mariusbutuc/5038826 to your computer and use it in GitHub Desktop.
Save mariusbutuc/5038826 to your computer and use it in GitHub Desktop.
Bootstrap Chef Solo
#!/usr/bin/env bash
# Apt-install various things necessary for Ruby etc.,
# and remove optional things to trim down the machine.
apt-get -y update
apt-get -y upgrade
apt-get -y install linux-headers-$(uname -r) build-essential
apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev
apt-get -y install vim
apt-get -y install git-core
apt-get clean
# Install Ruby from source.
RUBY_VERSION=1.9.3-p392
cd /tmp
wget -c http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-$RUBY_VERSION.tar.gz
tar -xvzf ruby-$RUBY_VERSION.tar.gz
cd ruby-$RUBY_VERSION
./configure --prefix=/usr/local
make
make install
cd ..
rm -rf ruby-$RUBY_VERSION
# Install RubyGems
RUBYGEMS_VERSION=1.8.25
wget -v http://production.cf.rubygems.org/rubygems/rubygems-$RUBYGEMS_VERSION.tgz
tar -xzf rubygems-$RUBYGEMS_VERSION.tgz
cd rubygems-$RUBYGEMS_VERSION
ruby setup.rb
cd ..
rm -rf rubygems-$RUBYGEMS_VERSION
# Install Chef Solo
## ruby-shadow is required to use the "password" attribute in Chef
## http://wiki.opscode.com/display/chef/Resources#Resources-PasswordShadowHash
gem install ruby-shadow --no-ri --no-rdoc
gem install chef --version '~> 10.24.0' --no-ri --no-rdoc
mkdir -p /etc/chef /var/chef/cookbooks
touch /etc/chef/solo.rb
# Remove items used for building, since they aren't needed anymore
apt-get -y remove linux-headers-$(uname -r) # build-essential
apt-get -y autoremove
@mariusbutuc
Copy link
Author

Prerequisites

  • curl
  • run as root (sudo su)

Usage

curl -L https://gist.github.com/mariusbutuc/5038826/raw/abf8c5351e80886bc2b33f86efcb7bfeb31430c3/chef_solo_bootstrap.sh | bash

More context:

@mariusbutuc
Copy link
Author

During the Opscode's Virtual Office Hours, @sethvargo suggested the Chef Omnibus installer, which also handles idempotency – I've missed handling it here.

@mariusbutuc
Copy link
Author

Downgraded RubyGems to latest pre-2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment