From 909cda4bd1d2a7335e51a54dde4973b51ae69bff Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 12 Apr 2014 14:46:57 -0700 Subject: [PATCH] provisioners/chef: reinit net shares on Windows guests --- plugins/provisioners/chef/provisioner/base.rb | 4 ++++ plugins/provisioners/chef/provisioner/chef_client.rb | 8 ++++++++ plugins/provisioners/chef/provisioner/chef_solo.rb | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/plugins/provisioners/chef/provisioner/base.rb b/plugins/provisioners/chef/provisioner/base.rb index 4be66f346..f0e34a2ee 100644 --- a/plugins/provisioners/chef/provisioner/base.rb +++ b/plugins/provisioners/chef/provisioner/base.rb @@ -138,6 +138,10 @@ module VagrantPlugins File.join(@config.provisioning_path, "encrypted_data_bag_secret_key") end end + + def windows? + @machine.config.vm.communicator == :winrm + end end end end diff --git a/plugins/provisioners/chef/provisioner/chef_client.rb b/plugins/provisioners/chef/provisioner/chef_client.rb index 2e5f07b64..50c8e82eb 100644 --- a/plugins/provisioners/chef/provisioner/chef_client.rb +++ b/plugins/provisioners/chef/provisioner/chef_client.rb @@ -58,6 +58,14 @@ module VagrantPlugins @machine.ui.warn(I18n.t("vagrant.chef_run_list_empty")) end + if windows? + # This re-establishes our symbolic links if they were + # created between now and a reboot + @machine.communicate.execute( + "& net use a-non-existant-share", + error_check: false) + end + command_env = @config.binary_env ? "#{@config.binary_env} " : "" command_args = @config.arguments ? " #{@config.arguments}" : "" command = "#{command_env}#{chef_binary_path("chef-client")} " + diff --git a/plugins/provisioners/chef/provisioner/chef_solo.rb b/plugins/provisioners/chef/provisioner/chef_solo.rb index 7f9e304ac..394111c02 100644 --- a/plugins/provisioners/chef/provisioner/chef_solo.rb +++ b/plugins/provisioners/chef/provisioner/chef_solo.rb @@ -134,6 +134,14 @@ module VagrantPlugins @machine.ui.warn(I18n.t("vagrant.chef_run_list_empty")) end + if windows? + # This re-establishes our symbolic links if they were + # created between now and a reboot + @machine.communicate.execute( + "& net use a-non-existant-share", + error_check: false) + end + options = [ "-c #{@config.provisioning_path}/solo.rb", "-j #{@config.provisioning_path}/dna.json"