hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.08k stars 3.33k forks source link

Issue: WinRM times out #8650

Closed GloverChris closed 4 years ago

GloverChris commented 4 years ago

Hello, I have a problem where WinRM is not connecting to an instance. I took a look at your documentation before submitting this issue and it was not helpful for my situation.

Things Ive done in the trouble shooting:

Things I have noticed: It seems as if the user_data_file isnt running on the host. Data backing this assumption is the fact that I cannot ping WinRM ports on the server and I have validated that I dont see the reg keys in windows registry that Im setting as part of WinRM configuration.

[1] https://gist.github.com/GloverChris/d28280d41278d4a7753b77cc248ec2ac

nywilken commented 4 years ago

Hi @GloverChris thanks for reaching out. It is possible that the user_data file has not executed so winrm is not setup within the timeout window you are setting 15m. We generally default the timeout to 30m because WinRM can take time. As you are working on AWS you may want to set a longer timeout; I've seen the cloud_int process take a little time to kick off.

Seeing as you are able to connect to via RDP, you may want to try bumping the winrm_timeout to something extreme 120m then via RDP connect and check the AWS cloud init logs to ensure that the user_data_file executes without issues.

If you run the SetupWinRM.ps1 script manually via RDP is Packer able to connect via WinRM?

Note: manually running of the SetupWinRM.ps1 should not be needed for Packer, but I would like to try and determine if it is a connectivity issue or just an issue with WinRM not being ready.

SwampDragons commented 4 years ago

Hi again! Thanks for reaching out.

By default, you aren't allowed to connect via WinRM via any user other than the Administrator user. There's some Windows-side configuration you have to do, I think it's possible to do but I personally haven't done it. Normally when I run windows builds I just use the Administrator user for this reason.

When I changed your user to Administrator in the Packer config and your SetupWinRM.ps1 file, Packer was able to connect.

I'm going to close since I was able to reproduce and then tweak your config to get it working, and this is a general WinRM issue not a Packer one. If you end up needing more help with this kind of initial configuration, the mailing list or community forum are generally more useful. Issues opened here on the Packer issue tracker are only viewed by a small handful of developers who work on the tool, and we don't always have the most depth or experience when it comes to custom issues with particular build configurations.

Thanks!

GloverChris commented 4 years ago

Thanks @SwampDragons ! you are once again super awsome!

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.