Skip to content

Instantly share code, notes, and snippets.

@AlainODea
Created May 21, 2014 04:44
Show Gist options
  • Save AlainODea/738fe18d7ac73fd00f46 to your computer and use it in GitHub Desktop.
Save AlainODea/738fe18d7ac73fd00f46 to your computer and use it in GitHub Desktop.
Chef knife bootstrap distro template for Joyent SmartMachines

joyent-smartmachine.erb

Chef knife bootstrap distro template for Joyent SmartMachines

Usage

Place in .chef/bootstrap/ Add --distro joyent-smartmachine to your knife bootstrap command.

# Modified based on: https://github.com/opscode/chef/blob/663c7dafdbdf833af331c7a1758af990fa7834be/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb
bash -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\" ; export https_proxy=\"$http_proxy\"" if knife_config[:bootstrap_proxy] -%>
if [ ! -f /opt/local/bin/chef-client ]; then
pkgin -f -y update
pkgin -f -y upgrade
pkgin -y install build-essential ruby193-rubygems pkg-config
gem install ohai --no-ri --no-rdoc
gem install chef --no-ri --no-rdoc <%= bootstrap_version_string %>
fi
mkdir -p /etc/chef
cat > /etc/chef/validation.pem <<'EOP'
<%= validation_key %>
EOP
chmod 0600 /etc/chef/validation.pem
<% if encrypted_data_bag_secret -%>
cat > /etc/chef/encrypted_data_bag_secret <<'EOP'
<%= encrypted_data_bag_secret %>
EOP
chmod 0600 /etc/chef/encrypted_data_bag_secret
<% end -%>
<%# Generate Ohai Hints -%>
<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
mkdir -p /etc/chef/ohai/hints
<% @chef_config[:knife][:hints].each do |name, hash| -%>
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
<%= hash.to_json %>
EOP
<% end -%>
<% end -%>
cat > /etc/chef/client.rb <<'EOP'
<%= config_content %>
EOP
cat > /etc/chef/first-boot.json <<'EOP'
<%= first_boot.to_json %>
EOP
<%= start_chef %>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment