-
-
Save jtimberman/1960051 to your computer and use it in GitHub Desktop.
Mac OS X 10.7 (Lion) Bootstrapping
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
ssl_verify_mode :verify_peer | |
ssl_ca_file CA_FILE | |
log_level :info | |
log_location STDOUT | |
chef_server_url 'SERVER_URL' | |
validation_client_name 'ORGNAME-validator' | |
node_name 'NODE_NAME' | |
base_dir = "#{ENV['HOME']}/.chef" | |
# Paths | |
checksum_path "#{base_dir}/checksum" | |
file_cache_path "#{base_dir}/cache" | |
file_backup_path "#{base_dir}/backup" | |
cache_options({:path => "#{base_dir}/cache/checksums", :skip_expires => true}) |
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 | |
set -e | |
# # Mac OS X 10.7 (Lion) Bootstrapping | |
# | |
# ## Pre-requisites | |
# | |
# * Set your hostname: In **System Preferences** go to **Sharing** and enter | |
# the name in **Computer Name** | |
# * Run **Software Update** and reboot if necessary | |
# * Install **Xcode** from the App Store (ugh) | |
# * Fetch your Opscode platform validator key and ensure it's in `~/Downloads` | |
# | |
# ## Running | |
# | |
# cd $HOME | |
# curl -sLO https://raw.github.com/gist/1100372/macosx_lion_bootstrap.sh | |
# chmod 755 macosx_lion_bootstrap.sh && sudo echo ok | |
# ./macosx_lion_bootstrap.sh | |
# | |
printf "Attempting to sudo (hopefully last time)...\n" | |
sudo echo | |
printf "Done.\n" | |
for d in /etc/chef /opt /etc/profile.d ; do | |
printf "===> Creating directory [${d}] ... " | |
sudo mkdir -p $d && sudo chown ${USER} $d | |
printf "Done.\n" | |
done ; unset d | |
printf "===> Preparing directories for Homebrew ... " | |
sudo mkdir -p /usr/local | |
sudo chgrp staff /usr/local | |
sudo chmod g+w /usr/local | |
printf "Done.\n" | |
if [[ -f "/etc/chef/client.rb" && -f "/etc/chef/validation.pem" ]] ; then | |
printf "\n===> File /etc/chef/client.rb and /etc/chef/validation.pem " | |
printf "already exist, so we will use them...\n\n" | |
else | |
printf "\nEnter full node name [ex: bubbles, crank.example.com]\n> " | |
read NODE_NAME | |
printf "\nEnter Chef Server URL " | |
printf "[default: https://api.opscode.com/organizations/YOURORGNAME]\n> " | |
read SERVER_URL | |
if [[ -z "$SERVER_URL" ]] ; then | |
printf "\nEnter Hosted Chef Orgname\n> " | |
read ORGNAME | |
SERVER_URL="https://api.opscode.com/organizations/$ORGNAME" | |
else | |
printf "\nEnter path to the SSL Certificate Authority Public Cert file " | |
printf "[default is to skip]\n> " | |
read CA_FILE_SRC | |
if [[ -z "$CA_FILE_SRC" ]] ; then | |
CA_FILE="nil" | |
else | |
if [[ ! -f "$CA_FILE_SRC" ]] ; then | |
printf ">>>> The CA file could not be found at: ${CA_FILE_SRC}.\n" | |
printf " Please copy the file here and retry.\n\n" | |
exit 1 | |
fi | |
CA_FILE="\'/etc/chef/chef_ca.pem\'" | |
fi | |
ORGNAME="chef" | |
fi | |
printf "\n\n===> Using Chef Server [${SERVER_URL}].\n\n" | |
KEY="$HOME/Downloads/${ORGNAME}-validator.pem" | |
if [[ ! -f "$KEY" ]] ; then | |
printf ">>>> The validator key could not be found at: $KEY.\n" | |
printf " Please copy the file here and retry.\n\n" | |
exit 1 | |
fi | |
printf "===> Preparing /etc/chef/client.rb ...\n" | |
(cd /etc/chef && curl -LO https://raw.github.com/gist/1100372/client.rb && \ | |
ruby -pi \ | |
-e "gsub 'ORGNAME', '${ORGNAME}'" \ | |
-e "gsub 'SERVER_URL', '${SERVER_URL}'" \ | |
-e "gsub 'CA_FILE', '${CA_FILE}'" \ | |
-e "gsub 'NODE_NAME', '${NODE_NAME}'" client.rb) | |
printf "===> Installing validation key [$KEY] ... " | |
mv $KEY /etc/chef/validation.pem | |
printf "Done.\n" | |
printf "===> Installing CA file [$CA_FILE_SRC] ... " | |
mv $CA_FILE_SRC /etc/chef/chef_ca.pem | |
printf "Done.\n" | |
fi | |
for g in chef rvm homesick ; do | |
printf "===> Installing [$g] gem...\n" | |
sudo gem install $g --no-ri --no-rdoc | |
done ; unset g | |
printf "===> Modifying PATH for Python/pip installation ... " | |
PATH="/usr/local/bin:/usr/local/share/python:$PATH" | |
export PATH | |
printf "Done.\n" | |
printf "===> Executing chef-client run ...\n" | |
time chef-client | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment