summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-08-13 19:37:58 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-08-14 16:34:46 -0700
commit9598bd817e09c3cfeddb70071ba1c088d6724de9 (patch)
tree1382f111d616b22ade0626d49d1feb681672c6a2
parent654f05b3a03aecdcb25c6a2c9593b13d3163362a (diff)
downloadchef-9598bd817e09c3cfeddb70071ba1c088d6724de9.tar.gz
fix the real issue
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/knife/core/windows_bootstrap_context.rb14
-rw-r--r--spec/unit/knife/core/windows_bootstrap_context_spec.rb19
2 files changed, 25 insertions, 8 deletions
diff --git a/lib/chef/knife/core/windows_bootstrap_context.rb b/lib/chef/knife/core/windows_bootstrap_context.rb
index b7e72151f2..f4b614af15 100644
--- a/lib/chef/knife/core/windows_bootstrap_context.rb
+++ b/lib/chef/knife/core/windows_bootstrap_context.rb
@@ -160,9 +160,13 @@ class Chef
def start_chef
c_opscode_dir = ChefConfig::PathHelper.cleanpath(ChefConfig::Config.c_opscode_dir, windows: true)
+ client_rb = clean_etc_chef_file("client.rb")
+ first_boot = clean_etc_chef_file("first-boot.json")
+
bootstrap_environment_option = bootstrap_environment.nil? ? "" : " -E #{bootstrap_environment}"
+
start_chef = "SET \"PATH=%SYSTEM32%;%SystemRoot%;%SYSTEM32%\\Wbem;%SYSTEM32%\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;#{c_opscode_dir}\\bin;#{c_opscode_dir}\\embedded\\bin\;%PATH%\"\n"
- start_chef << "#{Chef::Dist::CLIENT} -c c:/chef/client.rb -j #{ChefConfig::Config.etc_chef_dir(windows: true)}/first-boot.json#{bootstrap_environment_option}\n"
+ start_chef << "#{Chef::Dist::CLIENT} -c #{client_rb} -j #{first_boot}#{bootstrap_environment_option}\n"
end
def win_wget
@@ -262,6 +266,14 @@ class Chef
install_command('"') + "\n" + fallback_install_task_command
end
+ def clean_etc_chef_file(path)
+ ChefConfig::PathHelper.cleanpath(etc_chef_file(path), windows: true)
+ end
+
+ def etc_chef_file(path)
+ "#{bootstrap_directory}/#{path}"
+ end
+
def bootstrap_directory
ChefConfig::Config.etc_chef_dir(windows: true)
end
diff --git a/spec/unit/knife/core/windows_bootstrap_context_spec.rb b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
index 77e16f1a4a..ab38233714 100644
--- a/spec/unit/knife/core/windows_bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
@@ -149,12 +149,12 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
describe "#config_content" do
before do
bootstrap_context.instance_variable_set(:@chef_config, Mash.new(config_log_level: :info,
- config_log_location: STDOUT,
- chef_server_url: "http://chef.example.com:4444",
- validation_client_name: "chef-validator-testing",
- file_cache_path: "c:/chef/cache",
- file_backup_path: "c:/chef/backup",
- cache_options: ({ path: "c:/chef/cache/checksums", skip_expires: true })))
+ config_log_location: STDOUT,
+ chef_server_url: "http://chef.example.com:4444",
+ validation_client_name: "chef-validator-testing",
+ file_cache_path: "c:/chef/cache",
+ file_backup_path: "c:/chef/backup",
+ cache_options: ({ path: "c:/chef/cache/checksums", skip_expires: true })))
end
it "generates the config file data" do
@@ -183,7 +183,12 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
describe "#start_chef" do
it "returns the expected string" do
- expect(bootstrap_context.start_chef).to match(/SET "PATH=%SYSTEM32%;%SystemRoot%;%SYSTEM32%\\Wbem;%SYSTEM32%\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin;%PATH%"/)
+ expect(bootstrap_context.start_chef).to eq(
+ <<~EOH
+ SET "PATH=%SYSTEM32%;%SystemRoot%;%SYSTEM32%\\Wbem;%SYSTEM32%\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin;%PATH%"
+ chef-client -c C:\\chef\\client.rb -j C:\\chef\\first-boot.json
+ EOH
+ )
end
end