summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc A. Paradise <marc.paradise@gmail.com>2019-05-07 17:59:20 -0400
committerMarc A. Paradise <marc.paradise@gmail.com>2019-05-07 18:05:39 -0400
commit34c900c93f091114d5213bc22027bafd2d2704c5 (patch)
tree8696cc12101b85f179c63967aa2e35fa50118f50
parent6fc8b5f7f36b754aab979a56ece68500ab2ad87e (diff)
downloadchef-34c900c93f091114d5213bc22027bafd2d2704c5.tar.gz
Check for directories on Windows before creating
Under Chef 14 bootstrap, creation of directories that already existed in Windows would log an error, but not raise an error. With the Chef 15 bootstrap change to run the bootstrap script under powershell, any error in the script now causes an error to be raised up. Even though the bootstrap complets successfully - the script execution does not halt on error - it presents a confusing error to the human that makes it look like bootstrap failed. Fixes CHEF-8469 Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
-rw-r--r--lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb b/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb
index fd7b48f28d..1ac0b23755 100644
--- a/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb
+++ b/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb
@@ -235,13 +235,19 @@ echo Validation key written.
<% end -%>
<% unless trusted_certs_script.empty? -%>
-mkdir <%= bootstrap_directory %>\trusted_certs
+ @if NOT EXIST <%= bootstrap_directory %>\trusted_certs (
+ mkdir <%= bootstrap_directory %>\trusted_certs
+ )
+ )
+
<%= trusted_certs_script %>
<% end -%>
<%# Generate Ohai Hints -%>
<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
-mkdir <%= bootstrap_directory %>\ohai\hints
+ @if NOT EXIST <%= bootstrap_directory %>\ohai\hints (
+ mkdir <%= bootstrap_directory %>\ohai\hints
+ )
<% @chef_config[:knife][:hints].each do |name, hash| -%>
> <%= bootstrap_directory %>\ohai\hints\<%= name %>.json (
@@ -259,7 +265,10 @@ mkdir <%= bootstrap_directory %>\ohai\hints
)
<% unless client_d.empty? -%>
- mkdir <%= bootstrap_directory %>\client.d
+ @if NOT EXIST <%= bootstrap_directory %>\client.d (
+ mkdir <%= bootstrap_directory %>\client.d
+ )
+
<%= client_d %>
<% end -%>