Skip to content

Instantly share code, notes, and snippets.

@tmatilai
Created May 20, 2013 13:56
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tmatilai/5612377 to your computer and use it in GitHub Desktop.
Save tmatilai/5612377 to your computer and use it in GitHub Desktop.
Chef `knife bootstrap` template for Debian 7.0 Wheezy until it is supported by Opscode: http://tickets.opscode.com/browse/CHEF-4125
bash -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
exists() {
if command -v $1 &>/dev/null
then
return 0
else
return 1
fi
}
if ! exists /usr/bin/chef-client; then
tmp_dir=$(mktemp -d) || exit 1
apt-get install -y ca-certificates wget
chef_deb="https://www.opscode.com/chef/download?v=<%= chef_version %>&p=debian&pv=6&m=$(uname -m)"
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> "$chef_deb" -O "$tmp_dir/chef.deb"
dpkg -i "$tmp_dir/chef.deb"
rm -r "$tmp_dir"
fi
mkdir -p /etc/chef
awk NF > /etc/chef/validation.pem <<'EOP'
<%= validation_key %>
EOP
chmod 0600 /etc/chef/validation.pem
<% if encrypted_data_bag_secret -%>
awk NF > /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 %>'
@mrjcleaver
Copy link

Hi Teemu - does your gist still work for you:

I get an error:

162.250.192.77 Connecting to www.opscode.com (www.opscode.com)|184.106.28.91|:443... connected.
DEBUG: read 84 bytes
DEBUG: received packet nr 24 type 94 len 60
INFO: channel_data: 0 40b
DEBUG: read 100 bytes
DEBUG: received packet nr 25 type 94 len 76
INFO: channel_data: 0 60b
162.250.192.77 HTTP request sent, awaiting response... 404 Not Found
162.250.192.77 2014-09-28 13:12:56 ERROR 404: Not Found.
162.250.192.77 
DEBUG: read 260 bytes
DEBUG: received packet nr 26 type 94 len 236
INFO: channel_data: 0 207b
162.250.192.77 dpkg-deb: error: `/tmp/tmp.eR9jDmlxL2/chef.deb' is not a debian format archive
162.250.192.77 dpkg: error processing /tmp/tmp.eR9jDmlxL2/chef.deb (--install):
162.250.192.77  subprocess dpkg-deb --control returned error exit status 2
DEBUG: read 116 bytes
DEBUG: received packet nr 27 type 94 len 92
INFO: channel_data: 0 74b
162.250.192.77 Errors were encountered while processing:
162.250.192.77  /tmp/tmp.eR9jDmlxL2/chef.deb
DEBUG: read 168 bytes
DEBUG: received packet nr 28 type 98 len 44
INFO: channel_request: 0 exit-status false
DEBUG: received packet nr 29 type 94 len 76
INFO: channel_data: 0 47b
162.250.192.77 bash: line 71: chef-client: command not found

This relates to chef/chef#2037 (comment)

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