Skip to content

Instantly share code, notes, and snippets.

@mschueler
Created September 14, 2011 02:43
Show Gist options
  • Save mschueler/1215745 to your computer and use it in GitHub Desktop.
Save mschueler/1215745 to your computer and use it in GitHub Desktop.
#!/bin/bash
rgemurl="http://production.cf.rubygems.org/rubygems/"
rgem="rubygems-1.8.5"
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
apt-get update
APT_GET="env DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -q"
$APT_GET -y remove ruby1.8*
$APT_GET -y install ruby1.9.1 ruby1.9.1-dev libruby1.9.1 libopenssl-ruby1.9.1
$APT_GET -y install build-essential
ln -sf ruby1.9.1 /usr/bin/ruby
cd /tmp
wget "${rgemurl}${rgem}.tgz"
tar zxf "${rgem}.tgz"
cd "${rgem}"
ruby setup.rb --no-format-executable
ln -sf gem1.9.1 /usr/bin/gem
gem install --no-rdoc --no-ri chef
gem install --no-rdoc --no-ri ohai
mkdir -p /var/{log,backups,run,cache,lib}/chef
mkdir /etc/chef
cat - >/etc/chef/bootstrap.json <<EOF
{
"run_list": [
"role[base]",
"role[production]",
"role[database]"
],
"default_attributes": {
},
"override_attributes": {
}
}
EOF
cat - >/etc/chef/client.rb <<EOF
log_level :info
log_location "/var/log/chef/client.log"
ssl_verify_mode :verify_none
validation_client_name "<your>-validator"
validation_key "/etc/chef/validation.pem"
client_key "/etc/chef/client.pem"
chef_server_url "https://api.opscode.com/organizations/<yours>"
file_cache_path "/var/cache/chef"
file_backup_path "/var/backups/chef"
pid_file "/var/run/chef/client.pid"
node_name "`curl http://169.254.169.254/latest/meta-data/instance-id`"
Chef::Log::Formatter.show_time = true
EOF
cat - >/etc/chef/validation.pem <<EOF
-----BEGIN RSA PRIVATE KEY-----
<put your validation.pem here>
-----END RSA PRIVATE KEY-----
EOF
/usr/bin/chef-client -j /etc/chef/bootstrap.json -P /var/run/chef/client.pid -N pl-db20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment