Skip to content

Instantly share code, notes, and snippets.

@marccampbell
Forked from benjaminws/joyent-smartos.erb
Created August 22, 2012 22:15
Show Gist options
  • Save marccampbell/3429955 to your computer and use it in GitHub Desktop.
Save marccampbell/3429955 to your computer and use it in GitHub Desktop.
joyent-smartos.erb
# shove this in ~/.chef/bootstrap/joyent-smartos.erb
# run knife bootstrap <hostname> -d joyent-smartos
bash -c '
if [ ! -f /opt/local/bin/chef-client ]; then
cd /tmp
sudo pkgin -y install gcc-compiler gcc-runtime gcc-tools-0 ruby19 scmgit-base scmgit-docs gmake
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
tar -xzf rubygems-1.8.10.tgz
cd rubygems-1.8.10
sudo ruby setup.rb --no-format-executable
sudo gem install --no-ri --no-rdoc json_pure
sudo gem install --no-ri --no-rdoc -v=10.12.0 chef
sudo mv /opt/local/lib/ruby/gems/1.9/gems/json-1.4.6 /tmp/
sudo ln -s /opt/local/lib/ruby/gems/1.9/gems/json_pure-1.6.1 /opt/local/lib/ruby/gems/1.9/gems/json-1.4.6
fi
if [ ! -f /etc/chef ]; then
sudo mkdir -p /etc/chef
sudo chown admin /etc/chef
sudo chgrp staff /etc/chef
fi
OLD_HOSTNAME=`hostname`
NEW_HOSTNAME=<%= @config[:chef_node_name] %>
hostname $NEW_HOSTNAME
sed -i "s/$OLD_HOSTNAME/$NEW_HOSTNAME/g" /etc/hosts
(
cat <<'EOP'
<%= validation_key %>
EOP
) > /tmp/validation.pem
awk NF /tmp/validation.pem > /etc/chef/validation.pem
rm /tmp/validation.pem
(
cat <<'EOP'
<%= config_content %>
EOP
) > /etc/chef/client.rb
(
cat <<'EOP'
<%= { "run_list" => @run_list }.to_json %>
EOP
) > /etc/chef/first-boot.json
echo "<%= start_chef %>"
<%= start_chef %>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment