diff options
author | Tim Smith <tsmith@chef.io> | 2019-05-29 17:22:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-29 17:22:47 -0700 |
commit | 279e7ada623d902908c035bc66eaf7668c012634 (patch) | |
tree | 860724c20a3e7fb9cf23a30a687fc746610c45cb | |
parent | 7cf30cb18284a6311f52bf0cef3d32e661222092 (diff) | |
parent | d78f7da1d0e0852520db7103346eebae23ec42d5 (diff) | |
download | chef-279e7ada623d902908c035bc66eaf7668c012634.tar.gz |
Merge pull request #8611 from chef/backport_10
Use exports compatibile with /bin/sh in the bootstrap script
-rw-r--r-- | lib/chef/knife/bootstrap/templates/chef-full.erb | 3 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 22 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/chef/knife/bootstrap/templates/chef-full.erb b/lib/chef/knife/bootstrap/templates/chef-full.erb index 094cca1c08..35699ef6f5 100644 --- a/lib/chef/knife/bootstrap/templates/chef-full.erb +++ b/lib/chef/knife/bootstrap/templates/chef-full.erb @@ -1,5 +1,6 @@ sh -c ' -<%= "export https_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%> +<%= "https_proxy=\"#{knife_config[:bootstrap_proxy]}\" export https_proxy" if knife_config[:bootstrap_proxy] %> +<%= "no_proxy=\"#{knife_config[:bootstrap_no_proxy]}\" export no_proxy" if knife_config[:bootstrap_no_proxy] %> if test "x$TMPDIR" = "x"; then tmp="/tmp" diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index 258d193cf1..76b9d49a8c 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -96,6 +96,28 @@ describe Chef::Knife::Bootstrap do end end + context "with --bootstrap-proxy" do + let(:bootstrap_cli_options) { [ "--bootstrap-proxy", "1.1.1.1" ] } + let(:rendered_template) do + knife.merge_configs + knife.render_template + end + it "configures the https_proxy environment variable in the bootstrap template correctly" do + expect(rendered_template).to match(%r{https_proxy="1.1.1.1" export https_proxy}) + end + end + + context "with --bootstrap-no-proxy" do + let(:bootstrap_cli_options) { [ "--bootstrap-no-proxy", "localserver" ] } + let(:rendered_template) do + knife.merge_configs + knife.render_template + end + it "configures the https_proxy environment variable in the bootstrap template correctly" do + expect(rendered_template).to match(%r{no_proxy="localserver" export no_proxy}) + end + end + context "with :bootstrap_template and :template_file cli options" do let(:bootstrap_cli_options) { [ "--bootstrap-template", "my-template", "other-template" ] } |