Created
May 26, 2011 16:43
-
-
Save michaelvobrien/993491 to your computer and use it in GitHub Desktop.
Bootstrap Chef Solo on Ubuntu
This file contains 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
#!/usr/bin/env bash | |
export CHEF_DIR="${HOME}/cheftest" | |
rm -rf $CHEF_DIR/* | |
rm -rf $CHEF_DIR/.git* | |
mkdir -p "$CHEF_DIR" | |
sudo apt-get install ruby ruby-dev libopenssl-ruby rdoc ri irb build-essential wget ssl-cert git | |
cd /tmp | |
wget -c http://production.cf.rubygems.org/rubygems/rubygems-1.7.2.tgz | |
tar zxf rubygems-1.7.2.tgz | |
cd rubygems-1.7.2 | |
sudo ruby setup.rb --no-format-executable | |
if [[ ! (`command -v ohai` && `command -v chef-solo`) ]]; then | |
sudo gem install chef ohai --no-ri --no-rdoc | |
fi | |
mkdir -p "$HOME/.chef" | |
cat <<EOF > $HOME/.chef/knife.rb | |
log_level :debug | |
log_location STDOUT | |
node_name 'cheftest' | |
cookbook_path [ '$CHEF_DIR/cookbooks', '$CHEF_DIR/site-cookbooks' ] | |
cookbook_copyright "Cheftest Inc." | |
EOF | |
cd $CHEF_DIR | |
git clone git://github.com/opscode/chef-repo.git . | |
cat <<EOF > $CHEF_DIR/config/solo.rb | |
file_cache_path "$CHEF_DIR" | |
cookbook_path "$CHEF_DIR/cookbooks" | |
roles_path "$CHEF_DIR/roles" | |
json_attribs "$CHEF_DIR/config/default.json" | |
EOF | |
cat <<EOF > $CHEF_DIR/config/default.json | |
{ "run_list": ["recipe[default]" ] } | |
EOF | |
knife cookbook create default | |
printf " | |
=== Edit recipe (optional) === | |
vi $CHEF_DIR/cookbooks/default/recipes/default.rb | |
" | |
printf " | |
=== Run the following === | |
sudo chef-solo -c $CHEF_DIR/config/solo.rb | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment