diff --git a/CHANGELOG.md b/CHANGELOG.md index f87e0b115..f047c967e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ BUG FIXES: - commands/push: push lookups are by user-defined name, not push strategy name [GH-4975] - commands/push: validate the configuration + - communicators/winrm: detect parse errors in PowerShell and error - guests/arch: fix network configuration due to poor line breaks. [GH-4964] - guests/solaris: Merge configurations properly so configs can be set in default Vagrantfiles. [GH-5092] diff --git a/plugins/communicators/winrm/shell.rb b/plugins/communicators/winrm/shell.rb index 353c0e84d..2a116ec30 100644 --- a/plugins/communicators/winrm/shell.rb +++ b/plugins/communicators/winrm/shell.rb @@ -93,7 +93,23 @@ module VagrantPlugins block.call(:stdout, out) if block_given? && out block.call(:stderr, err) if block_given? && err end + @logger.debug("Output: #{output.inspect}") + + # Verify that we didn't get a parser error, and if so we should + # set the exit code to 1. Parse errors return exit code 0 so we + # need to do this. + if output[:exitcode] == 0 + (output[:data] || []).each do |data| + next if !data[:stderr] + if data[:stderr].include?("ParserError") + @logger.warn("Detected ParserError, setting exit code to 1") + output[:exitcode] = 1 + break + end + end + end + return output end end