Chef knife bootstrap distro template for Joyent SmartMachines
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 %>' |