This repository has been archived by the owner on Jul 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bootstrap script to properly upgrade, set the hostname, and boots…
…trap chef onto new instances
Sam Kottler
committed
Jun 21, 2014
1 parent
3601424
commit a3c9592
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
' |