Skip to content

Instantly share code, notes, and snippets.

@kashif
Forked from bensie/chef_bootstrap_rvm.erb
Created October 10, 2011 11:58
Show Gist options
  • Save kashif/1275138 to your computer and use it in GitHub Desktop.
Save kashif/1275138 to your computer and use it in GitHub Desktop.
Chef bootstrap With rvm and ruby 1.9.3 on ubuntu 11.10
bash -c '
<% if knife_config[:bootstrap_proxy] -%>
(
cat <<'EOP'
<%= "proxy = #{knife_config[:bootstrap_proxy]}" %>
EOP
) > ~/.curlrc
<% end -%>
if [ ! -f /usr/bin/chef-client ]; then
apt-get update
apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
source /etc/profile
rvm install 1.9.3 <%= "--proxy #{knife_config[:bootstrap_proxy]}" if knife_config[:bootstrap_proxy] %>
rvm use 1.9.3 --default
fi
source /etc/profile
gem update --system --no-rdoc --no-ri
gem update --no-rdoc --no-ri
gem install ohai --no-rdoc --no-ri --verbose
gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
if [ -f /usr/bin/chef-client ]; then
rm -f /usr/bin/chef-client
fi
ln -nfs $(which chef-client) /usr/bin/chef-client
mkdir -p /etc/chef
(
cat <<'EOP'
<%= validation_key %>
EOP
) > /tmp/validation.pem
awk NF /tmp/validation.pem > /etc/chef/validation.pem
rm /tmp/validation.pem
<% if @chef_config[:encrypted_data_bag_secret] -%>
(
cat <<'EOP'
<%= encrypted_data_bag_secret %>
EOP
) > /tmp/encrypted_data_bag_secret
awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
rm /tmp/encrypted_data_bag_secret
<% end -%>
(
cat <<'EOP'
<%= config_content %>
EOP
) > /etc/chef/client.rb
(
cat <<'EOP'
<%= { "run_list" => @run_list }.to_json %>
EOP
) > /etc/chef/first-boot.json
<%= start_chef %>'
@kashif
Copy link
Author

kashif commented Oct 10, 2011

Place file in ~/chef-repo/.chef/bootstrap/ folder and bootstrap chef with

$ cd ~/chef-repo
$ knife bootstrap NODE --distro ubuntu-11.10-gems -x USERNAME --sudo

and then you should see:

$ knife node show NODE
Node Name:   NODE
Environment: _default
FQDN:        NODE
IP:          192.168.6.128
Run List:    
Roles:       
Recipes:     
Platform:    ubuntu 11.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment