Created
February 17, 2011 19:02
-
-
Save bleything/832382 to your computer and use it in GitHub Desktop.
A chef bootstrapper that provisions the machine with REE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# chef bootstrap script %> | |
<%# made by Estately, Inc. placed in the public domain. %> | |
bash -c ' | |
<%# let's get this party started %> | |
apt-get update | |
apt-get -y install build-essential wget | |
<%# install REE if necessary %> | |
if [ ! -f /usr/local/bin/ruby ]; then | |
cd /tmp | |
wget http://rubyforge.org/frs/download.php/71098/ruby-enterprise_1.8.7-2010.02_amd64_ubuntu10.04.deb | |
dpkg -i ruby-enterprise_1.8.7-2010.02_amd64_ubuntu10.04.deb | |
<%# remove all the gems that REE installs %> | |
gem list --no-versions | grep -i ^[a-z] | xargs gem uninstall --ignore-dependencies | |
fi | |
<%# install shadow if necessary %> | |
if [ ! -f /usr/local/lib/ruby/site_ruby/1.8/x86_64-linux/shadow.so ]; then | |
cd /tmp | |
apt-get source libshadow-ruby | |
cd libshadow-ruby-* | |
ruby extconf.rb | |
make | |
make install | |
fi | |
<%# install chef %> | |
if [ ! -f /usr/local/bin/chef-client ]; then | |
gem install ohai chef --no-rdoc --no-ri | |
fi | |
<%# now that that's out of the way, upgrade everything, clean up, and move on %> | |
apt-get -y dist-upgrade | |
apt-get -y --purge autoremove | |
<%# set up chef %> | |
mkdir -p /etc/chef | |
( | |
cat <<'EOP' | |
<%= IO.read(Chef::Config[:validation_key]) %> | |
EOP | |
) > /tmp/validation.pem | |
awk NF /tmp/validation.pem > /etc/chef/validation.pem | |
rm /tmp/validation.pem | |
chmod 700 /etc/chef/validation.pem | |
( | |
cat <<'EOP' | |
log_level :info | |
log_location STDOUT | |
chef_server_url "<%= Chef::Config[:chef_server_url] %>" | |
validation_client_name "<%= Chef::Config[:validation_client_name] %>" | |
node_name "<%= @config[:chef_node_name] %>" | |
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 && rm /etc/chef/first-boot.json /etc/chef/validation.pem && reboot' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment