summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Chamberland <chamberland.marc@gmail.com>2020-05-15 16:44:22 -0400
committerTim Smith <tsmith84@gmail.com>2020-05-22 09:00:28 -0700
commite28984bf00d680c0e38d8be2de300f3d73f616df (patch)
tree797b2098c286d431ec4c9373b72a22360adb702d
parent0017b8043ed717edb66e9e9d9c8f62e8ff55bf43 (diff)
downloadchef-e28984bf00d680c0e38d8be2de300f3d73f616df.tar.gz
fix windows bootstrap; replicate https://github.com/chef/chef/pull/9839 by Chad Jessup
This fixes bootstrapping on Windows. All credit goes to Chad Jessup <chad.jessup@gmail.com> but since the original PR was left without DCO I'm replicating it here, with valid DCO. Signed-off-by: Marc Chamberland <chamberland.marc@gmail.com>
-rw-r--r--lib/chef/knife/core/windows_bootstrap_context.rb4
-rw-r--r--spec/unit/knife/core/windows_bootstrap_context_spec.rb6
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/chef/knife/core/windows_bootstrap_context.rb b/lib/chef/knife/core/windows_bootstrap_context.rb
index fda29a08a6..aa2c61f1f5 100644
--- a/lib/chef/knife/core/windows_bootstrap_context.rb
+++ b/lib/chef/knife/core/windows_bootstrap_context.rb
@@ -158,8 +158,8 @@ class Chef
def start_chef
bootstrap_environment_option = bootstrap_environment.nil? ? "" : " -E #{bootstrap_environment}"
- start_chef = "SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;#{ChefConfig::Config.c_opscode_dir}\\#{ChefConfig::Dist::DIR_SUFFIX}\\bin;#{ChefConfig::Config.c_opscode_dir}\\#{ChefConfig::Dist::DIR_SUFFIX}\\embedded\\bin\;%PATH%\"\n"
- start_chef << "chef-client -c #{ChefConfig::Config.etc_chef_dir(true)}/client.rb -j #{ChefConfig::Config.etc_chef_dir(true)}/first-boot.json#{bootstrap_environment_option}\n"
+ start_chef = "SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;#{ChefConfig::Config.c_opscode_dir}\\bin;#{ChefConfig::Config.c_opscode_dir}\\embedded\\bin\;%PATH%\"\n"
+ start_chef << "#{Chef::Dist::CLIENT} -c #{ChefConfig::Config.etc_chef_dir(true)}/client.rb -j #{ChefConfig::Config.etc_chef_dir(true)}/first-boot.json#{bootstrap_environment_option}\n"
end
def win_wget
diff --git a/spec/unit/knife/core/windows_bootstrap_context_spec.rb b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
index 14ca563a58..96ac00e1ad 100644
--- a/spec/unit/knife/core/windows_bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
@@ -184,6 +184,12 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
end
end
+ describe "#start_chef" do
+ it "returns the expected string" do
+ expect(bootstrap_context.start_chef).to match(%r{SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\/opscode\/chef\\bin;C:\/opscode\/chef\\embedded\\bin\;%PATH%\"\n})
+ end
+ end
+
describe "msi_url" do
context "when msi_url config option is not set" do
let(:config) { { channel: "stable" } }