diff options
author | Claire McQuin <claire@getchef.com> | 2014-08-22 11:12:10 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-08-26 15:49:51 -0700 |
commit | 3812f7cb6b267014c4057cd6787b7fc2011ef816 (patch) | |
tree | aa243d522421364716df0da0bc020cedf6907668 /lib | |
parent | de8e2612785c1f9f4bdd05787dcc47d55ef348c6 (diff) | |
download | chef-3812f7cb6b267014c4057cd6787b7fc2011ef816.tar.gz |
Add --ssl-verify-mode and --[no-]verify-api-cert options.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 18 | ||||
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 8 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index cf4f3c7a0c..3c934431ec 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -188,6 +188,23 @@ class Chef :description => "Add options to curl when install chef-client", :proc => Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co } + option :ssl_verify_mode, + :long => "--ssl-verify-mode [none|all]", + :description => "Whether or not to verify the SSL cert for all HTTPS requests.", + :proc => Proc.new { |verify_mode| + if verify_mode == "all" + mode = :verify_peer + elsif verify_mode == "none" + mode = :verify_none + end + Chef::Config[:knife][:ssl_verify_mode] = mode + } + + option :verify_api_cert, + :long => "--[no-]verify-api-cert", + :description => "Verify the SSL cert for HTTPS requests to the Chef server API.", + :boolean => true + def bootstrap_template # For some reason knife.merge_configs doesn't pick up the default values from # Chef::Config[:knife][:bootstrap_template] unless Chef::Config[:knife][:bootstrap_template] @@ -204,6 +221,7 @@ class Chef if File.exists?(template) Chef::Log.debug("Using the specified bootstrap template: #{File.dirname(template)}") return template + end # Otherwise search the template directories until we find the right one diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 0fdd77594a..831a214e66 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -64,6 +64,14 @@ CONFIG client_rb << "# Using default node name (fqdn)\n" end + unless @config[:verify_api_cert].nil? + client_rb << %Q{verify_api_cert #{@config[:verify_api_cert]}\n} + end + + if knife_config[:ssl_verify_mode] + client_rb << %Q{ssl_verify_mode :#{knife_config[:ssl_verify_mode]}\n} + end + if knife_config[:bootstrap_proxy] client_rb << %Q{http_proxy "#{knife_config[:bootstrap_proxy]}"\n} client_rb << %Q{https_proxy "#{knife_config[:bootstrap_proxy]}"\n} |