Skip to content

Instantly share code, notes, and snippets.

@rcreasey
Created September 6, 2011 18:12
Show Gist options
  • Select an option

  • Save rcreasey/1198476 to your computer and use it in GitHub Desktop.

Select an option

Save rcreasey/1198476 to your computer and use it in GitHub Desktop.
bash -c '
announce() {
echo ""
echo "*** $1 ***"
}
announce "Updating SSL CA's"
curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt
announce "Installing Yum Repositories"
rpm -Uh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uh http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
announce "Installing Core Libraries"
yum install -q -y ruby ruby-devel gcc gcc-c++ automake autoconf rubygems make
if [ ! -x /usr/bin/gem ]; then
announce "Installing Rubygems"
gem update
fi
if [ -x /usr/bin/chef-client ]; then
announce "Updating Chef"
gem update ohai chef --no-rdoc --no-ri -q
else
announce "Installing Chef"
gem install ohai chef --no-rdoc --no-ri -q
fi
announce "Configuring Chef"
mkdir -p /etc/chef
announce " Seeding Validation Key"
(
cat <<'EOP'
<%= IO.read(Chef::Config[:validation_key]) %>
EOP
) | awk NF > /etc/chef/validation.pem
announce " Seeding Chef Configuration"
(
cat <<'EOP'
log_level :info
log_location STDOUT
chef_server_url "<%= Chef::Config[:chef_server_url] %>"
<% if @config[:chef_node_name] == nil %>
# Using default node name
<% else %>
node_name "<%= @config[:chef_node_name] %>"
<% end %>
validation_client_name "<%= Chef::Config[:validation_client_name] %>"
EOP
) | awk NF > /etc/chef/client.rb
announce " Seeding Bootstrap Run List"
(
cat <<'EOP'
<%= { "run_list" => @run_list }.to_json %>
EOP
) | awk NF > /etc/chef/bootstrap.json
announce " Starting up Chef Client"
announce " Joining '<%= @config[:chef_node_name] %>' to '<%= Chef::Config[:chef_server_url] %>'"
/usr/bin/chef-client -j /etc/chef/bootstrap.json
announce "Bootstrap Complete"
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment