Skip to content

Instantly share code, notes, and snippets.

@smith
Created March 15, 2012 20:39
Show Gist options
  • Save smith/2046747 to your computer and use it in GitHub Desktop.
Save smith/2046747 to your computer and use it in GitHub Desktop.
bootstrap for ubuntu
bash -c '
# Ubuntu Ruby 1.9.2 Chef bootstrap script
# Is chef-client not installed?
if [ ! `which chef-client` ]; then
apt-get update
apt-get install -y wget libffi5 build-essential
# Is ruby installed?
if [ `which ruby` ]; then
RUBY_VERSION=`ruby -e "print RUBY_VERSION"`
else
RUBY_VERSION="none"
fi
# Is our ruby not 1.9.2?
if [ "$RUBY_VERSION" != "1.9.2" ]; then
ARCH=`uname -m`
URL_PREFIX="http://c3222282.r82.cf0.rackcdn.com/"
PKG_NAME="ruby-5.0-1cramerdev1.9.2p180_"
case "$ARCH" in
x86_64|i386)
# use $ARCH as-is
;;
i686)
# i686 == i386
ARCH=i386
;;
*)
echo "Architechture $ARCH not supported"
exit 1
;;
esac
cd /tmp
PKG_NAME=$PKG_NAME$ARCH.deb
if [ ! -f "$PKG_NAME" ]; then
wget -q $URL_PREFIX$PKG_NAME
fi
dpkg -i $PKG_NAME
gem update --system
fi
gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
fi
mkdir -p /etc/chef
(
cat <<'EOP'
<%= validation_key %>
EOP
) > /tmp/validation.pem
awk NF /tmp/validation.pem > /etc/chef/validation.pem
rm /tmp/validation.pem
(
cat <<'EOP'
<%= config_content %>
verbose_logging false
EOP
) > /etc/chef/client.rb
(
cat <<'EOP'
<%= { "run_list" => @run_list }.to_json %>
EOP
) > /etc/chef/first-boot.json
chef-client -j /etc/chef/first-boot.json -E <%= bootstrap_environment %>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment