Created
July 23, 2011 13:53
-
-
Save jcsalterego/1101452 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
CHEF_ROLE=$1 | |
apt-get update; | |
# install ruby and other pre-requisites | |
apt-get install -y \ | |
build-essential \ | |
emacs23-nox \ | |
git \ | |
irb \ | |
libopenssl-ruby1.8 \ | |
rdoc \ | |
ri \ | |
ruby \ | |
ruby1.8 \ | |
ruby1.8-dev \ | |
rubygems1.8 \ | |
ssl-cert \ | |
wget \ | |
; | |
# install rubygems | |
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz | |
tar xvfz rubygems-1.3.7.tgz | |
cd rubygems-1.3.7 | |
ruby setup.rb | |
ln -sfv /usr/bin/gem1.8 /usr/bin/gem | |
# install chef via gem | |
gem install chef --no-ri --no-rdoc --verbose | |
# download chef scripts and configuration files | |
# note that CHEF_ROLE dictates with JSON file to use (associates client with that role) | |
mkdir -p /etc/chef | |
wget -qO/etc/chef/client.rb mysite.com/chef/client.rb | |
wget -qO/etc/chef/chef.json mysite.com/chef/chef.${CHEF_ROLE}.json | |
wget -qO/etc/chef/validation.pem mysite.com/chef/validation.pem | |
wget -qO/etc/init.d/chef-client mysite.com/chef/chef-client-init | |
# initial run of chef -- role association happens | |
chef-client -j /etc/chef/chef.json -L /var/log/chef.log -l debug | |
# remove validation key | |
rm -rf /etc/chef/validation.pem | |
# run init script and chkconfig it on | |
chmod +x /etc/init.d/chef-client | |
chkconfig chef-client on | |
/etc/init.d/chef-client start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment