Skip to content

Instantly share code, notes, and snippets.

@AlainODea
Last active December 19, 2015 23:29
Show Gist options
  • Save AlainODea/6035292 to your computer and use it in GitHub Desktop.
Save AlainODea/6035292 to your computer and use it in GitHub Desktop.
Joyent SmartMachine bootstrap with environment and proxy support.
bash -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_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 $(pkgin se rubygems | grep rubygems | cut -d" " -f1 | head -n1) 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 %>'
@AlainODea
Copy link
Author

Followed the latest ubuntu12.04-gems.erb to make a bootstrap that supports Ohai hints and supports chef-client without special parameters. Configuration is now stored in /etc/chef like other platforms.

This no longer includes the SMF instance which runs convergence with 30-minute delays between runs. Again, this change is intended to make the SmartMachine bootstrap consistent with other platforms.

I will provide an alternative bootstrap that includes the SMF service for those who want it.

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