TLDR; I finally figured out why this was failing for me: a !@#$%ing web
proxy!
The 503 error was being returned by the web proxy, *not* by the Windows
servers.
Once my temp Packer-launched instance was booted and the WinRM connectivity
was configured via a userdata PowerShell script, Packer was then trying to
connect via WinRM to run my various PS scripts, but failing because it was
trying to go through the web proxy to get to a private IP address.
My solution was to add the entire subnet's worth of IP address to the
*no_proxy* and *NO_PROXY* environment variable (luckily only a /24 for me).
E.g.:
printf -v no_proxy '%s,' 192.168.42.{1..255};
export no_proxy="169.254.169.254,$no_proxy"
export NO_PROXY=$no_proxy
What's weird is that this worked for a Win2008 image from what I'm 99% sure
is the same unaltered server. But I could be dead wrong.
Anyway, your best friend is Packer debugging. E.g.:
PACKER_LOG=1 PACKER_LOG_PATH=/tmp/packer.log packer build.json
HTH!
On Friday, September 1, 2017 at 2:58:40 PM UTC-4, Khalid Hosein wrote:
>
> Hello,
>
> I'm building Windows AMIs in AWS, and am having trouble connecting via
> WinRM to Win 2012 and 2016 versions. However, the same configs work for Win
> 2008 R2.
>
> When I enabled Packer debugging, I see the following errors (repeated
> until it hits the *winrm_timeout*):
>
> 2017/09/01 18:18:19 packer: 2017/09/01 18:18:19 [ERROR] connection error:
> http response error: 503 - invalid content type
> 2017/09/01 18:18:19 packer: 2017/09/01 18:18:19 [ERROR] WinRM connection
> err: http response error: 503 - invalid content type
>
>
> (BTW, searching for these errors either associated with 'winrm' and/or
> 'packer' does not return much. I also have a sense that the 'invalid
> content type' message is returned from Go.)
>
> Running packer build using Linux' strace didn't produce anything valuable.
>
> When the temporary instance boots, I can connect successfully to the WinRM
> port including using the *_pywinrm_* library to create a session using
> the credentials in my JSON config, so I know that my user data script is
> successfully enabling WinRM and setting the credentials.
>
> Is there something in particular that changed since Windows 2008?
> Is there a neat way to capture the WinRM commands/traffic that Packer is
> sending/receiving?
>
> Thanks!
>
> -- Khalid
>
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/14a99653-07f7-465d-9416-486e4bba2b7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.