summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-05-08 10:09:01 -0700
committerClaire McQuin <claire@getchef.com>2014-05-08 15:37:48 -0700
commit2481b6740b6de0ede97574e422dd2980a27b8363 (patch)
tree9e77640b94aee3f36aa0bfc5c9b47f51326b356d
parentca384a949df634ef1a2a1cd27df77c9fca02e097 (diff)
downloadchef-2481b6740b6de0ede97574e422dd2980a27b8363.tar.gz
add knife options for chef-full customization
-rw-r--r--CHANGELOG.md1
-rw-r--r--DOC_CHANGES.md6
-rw-r--r--lib/chef/knife/bootstrap.rb20
-rw-r--r--lib/chef/knife/bootstrap/chef-full.erb29
4 files changed, 43 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7d3afc44db..f8626bfb76 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,7 @@
* bootstrap no reports authentication failures. (CHEF-5161)
* `chef_gem` resource now uses omnibus gem binary. (CHEF-5092)
* `freebsd_package` resource now uses the brand new "pkgng" package manager when available. (CHEF-4637)
+* chef-full template gets knife options to override install script url, add wget/curl cli options, and custom install commands (CHEF-4697)
## Last Release: 11.12.0 RC1 (03/31/2014)
* SIGTERM will once-more kill a non-daemonized chef-client (CHEF-5172)
diff --git a/DOC_CHANGES.md b/DOC_CHANGES.md
index 504b6d688e..2987bf19b2 100644
--- a/DOC_CHANGES.md
+++ b/DOC_CHANGES.md
@@ -27,3 +27,9 @@ You can now easily set the environment for an existing node without editing the
```
knife node environment set NODE ENVIRONMENT
```
+### New configurable knife bootstrap options for chef-full template
+You can now modify the chef-full template with the following options in `knife bootstrap`:
+
+* `--bootstrap-install-sh URL` fetches and executes an installation bash script from the provided URL.
+* `--bootstrap-wget-options OPTIONS` and `--bootstrap-curl-options OPTIONS` allow arbitrary options to be added to wget and curl.
+* `--bootstrap-install-command COMMAND` can be used to execute a custom chef-client installation command sequence. Take note that this cannot be used in conjunction with the above options.
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index cb49cfbb2e..aae927e0ca 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -154,6 +154,26 @@ class Chef
:description => "A file containing the secret key to use to encrypt data bag item values",
:proc => Proc.new { |sf| Chef::Config[:knife][:secret_file] = sf }
+ option :bootstrap_url,
+ :long => "--bootstrap-url URL",
+ :description => "URL to a custom installation script",
+ :proc => Proc.new { |u| Chef::Config[:knife][:bootstrap_url] = u }
+
+ option :bootstrap_install_command,
+ :long => "--bootstrap-install-command COMMANDS",
+ :description => "Custom command to install chef-client",
+ :proc => Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic }
+
+ option :bootstrap_wget_options,
+ :long => "--bootstrap-wget-options OPTIONS",
+ :description => "Add options to wget when installing chef-client",
+ :proc => Proc.new { |wo| Chef::Config[:knife][:bootstrap_wget_options] = wo }
+
+ option :bootstrap_curl_options,
+ :long => "--bootstrap-curl-options OPTIONS",
+ :description => "Add options to curl when install chef-client",
+ :proc => Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co }
+
def find_template(template=nil)
# Are we bootstrapping using an already shipped template?
if config[:template_file]
diff --git a/lib/chef/knife/bootstrap/chef-full.erb b/lib/chef/knife/bootstrap/chef-full.erb
index 1d75117b72..c0b8d54dad 100644
--- a/lib/chef/knife/bootstrap/chef-full.erb
+++ b/lib/chef/knife/bootstrap/chef-full.erb
@@ -19,20 +19,23 @@ exists() {
fi
}
-install_sh="https://www.opscode.com/chef/install.sh"
-version_string="-v <%= chef_version %>"
-
-if ! exists /usr/bin/chef-client; then
- echo "Installing Chef Client..."
- if exists wget; then
- bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh} -O -) ${version_string}
- elif exists curl; then
- bash <(curl -L <%= "--proxy \"#{knife_config[:bootstrap_proxy]}\" " if knife_config[:bootstrap_proxy] %> ${install_sh}) ${version_string}
- else
- echo "Neither wget nor curl found. Please install one and try again." >&2
- exit 1
+<% if knife_config[:bootstrap_install_command] %>
+ <%= knife_config[:bootstrap_install_command] %>
+<% else %>
+ install_sh="<%= knife_config[:bootstrap_url] ? knife_config[:bootstrap_url] : "https://www.opscode.com/chef/install.sh" %>"
+ version_string="-v <%= chef_version %>"
+ if ! exists /usr/bin/chef-client; then
+ echo "Installing Chef Client..."
+ if exists wget; then
+ bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> <%= knife_config[:bootstrap_wget_options] %> ${install_sh} -O -) ${version_string}
+ elif exists curl; then
+ bash <(curl -L <%= "--proxy \"#{knife_config[:bootstrap_proxy]}\" " if knife_config[:bootstrap_proxy] %> <%= knife_config[:bootstrap_curl_options] %> ${install_sh}) ${version_string}
+ else
+ echo "Neither wget nor curl found. Please install one and try again." >&2
+ exit 1
+ fi
fi
-fi
+<% end %>
mkdir -p /etc/chef