-
-
Save AlainODea/6035292 to your computer and use it in GitHub Desktop.
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 %>' |
Add @jperkin's interim fix for non-zero exit codes on pkgin install on the latest SmartOS images.
As of 2013-09-09 the bootstrap on http://wiki.joyent.com/wiki/display/jpc2/Joyent+ChefServer+SmartMachine has a defect that prevents it from setting the chef_environment correctly on nodes being bootstrapped. It also has a defect in that it doesn't set the http_proxy for the running chef_client service. Both of these issues are addressed in my version.
My version also addresses a temporary issue in pkgin with base/base64 13.0.2 images where it exits with code 1 if the package being installed or any of its dependencies are already installed. The fix is @jperkin's upgrade of pkg_install which has the workaround (pkg_add -u pkg_install
).
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.
I have also included ongoing proxy support in the SMF manifest. Beforehand the http_proxy environment would be established for the bootstrap session, but not for the chef-client SMF instance.
This allows --bootstrap-proxy to carry into service invocations of chef-client (as would be expected).