Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Commit

Permalink
Add bootstrap script to properly upgrade, set the hostname, and boots…
Browse files Browse the repository at this point in the history
…trap chef onto new instances
  • Loading branch information
Sam Kottler committed Jun 21, 2014
1 parent 3601424 commit a3c9592
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .chef/bootstrap/rubygems-trusty.erb
@@ -0,0 +1,43 @@
bash -c '

echo <%= @config[:chef_node_name] %> > /etc/hostname
hostname -F /etc/hostname

echo "`ip addr | grep eth0 | grep "inet " | cut -d " " -f 6 | cut -d \/ -f 1` `cat /etc/hostname`" >> /etc/hosts

apt-get update
apt-get upgrade -y

mkdir -p /etc/chef

# Setup the validation key.
(
cat <<'EOP'
<%= IO.read(Chef::Config[:validation_key]) %>
EOP
) > /etc/chef/validation.pem

# Setup the client configuration.
(
cat <<'EOP'
log_level :info
log_location STDOUT
chef_server_url "<%= Chef::Config[:chef_server_url] %>"
validation_client_name "<%= Chef::Config[:validation_client_name] %>"
<% unless @config[:chef_node_name] == nil %>
node_name "<%= @config[:chef_node_name] %>"
<% end %>
EOP
) > /etc/chef/client.rb

(
cat <<'EOP'
<%= { "run_list" => @run_list }.to_json %>
EOP
) > /etc/chef/first-boot.json

curl -L https://www.opscode.com/chef/install.sh | sudo bash

/usr/bin/chef-client -j /etc/chef/first-boot.json

'

0 comments on commit a3c9592

Please sign in to comment.