diff --git a/plugins/provisioners/shell/config.rb b/plugins/provisioners/shell/config.rb index ae456f39e..b336b0c5c 100644 --- a/plugins/provisioners/shell/config.rb +++ b/plugins/provisioners/shell/config.rb @@ -17,6 +17,7 @@ module VagrantPlugins attr_accessor :sensitive attr_accessor :powershell_args attr_accessor :powershell_elevated_interactive + attr_accessor :reset def initialize @args = UNSET_VALUE @@ -31,6 +32,7 @@ module VagrantPlugins @keep_color = UNSET_VALUE @name = UNSET_VALUE @sensitive = UNSET_VALUE + @reset = UNSET_VALUE @powershell_args = UNSET_VALUE @powershell_elevated_interactive = UNSET_VALUE end @@ -48,6 +50,7 @@ module VagrantPlugins @keep_color = false if @keep_color == UNSET_VALUE @name = nil if @name == UNSET_VALUE @sensitive = false if @sensitive == UNSET_VALUE + @reset = false if @reset == UNSET_VALUE @powershell_args = "-ExecutionPolicy Bypass" if @powershell_args == UNSET_VALUE @powershell_elevated_interactive = false if @powershell_elevated_interactive == UNSET_VALUE @@ -68,7 +71,7 @@ module VagrantPlugins # Validate that the parameters are properly set if path && inline errors << I18n.t("vagrant.provisioners.shell.path_and_inline_set") - elsif !path && !inline + elsif !path && !inline && !reset errors << I18n.t("vagrant.provisioners.shell.no_path_or_inline") end diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index 3964c0a82..a77f9185e 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -18,6 +18,10 @@ module VagrantPlugins args = " #{args.join(" ")}" end + # In cases where the connection is just being reset + # bail out before attempting to do any actual provisioning + return if !config.path && !config.inline + case @machine.config.vm.communicator when :winrm provision_winrm(args) @@ -26,6 +30,8 @@ module VagrantPlugins else provision_ssh(args) end + ensure + @machine.communicate.reset! if config.reset end protected