boxcutter / windows

Virtual machine templates for Windows written in legacy JSON and Batch Scripting/JScript
Apache License 2.0
753 stars 266 forks source link

Windows Server 2016 templates block while asking the user a question at the networks dialog #213

Open arizvisa opened 4 years ago

arizvisa commented 4 years ago

When building any of the Windows 2016 templates (win2016-standard*.json, and eval-win2016-standard*.json), the build pauses while it asks the user the following via the Networks dialog.

Do you want to allow your PC to be discoverable by other PCs and devices on this network?

This is likely an issue in the floppy/.../autounattend.xml script.

arizvisa commented 4 years ago

This isn't actually blocking at that dialog but is blocking due to having issues downloading wget.exe from https://eternallybored.org due to unsupported SSL/TLS protocols. I've tested adding the required protocols to [System.Net.ServicePointManager]::SecurityProtocol to no avail...

One fix is to ask the owner of eternallybored.org to serve wget.exe over more widely available/insecure ssl/tls protocols... but since I don't know that guy and I'm not sure if here cares, this'll probably be ineffective.

I think the other way to fix this, would be to self-host wget.exe under packer's http server. :-/ But, I really wasn't planning on doing this yet w/o approval from the community.

arizvisa commented 4 years ago

Hmm..Ironically if I remove 01-install-wget.cmd from the floppy_files, then this issue goes away entirely. Downloading still works as well for win2k16 templates...(go figure).

Really.. this kind of stuff should be done during provisioning leaving only things such as installing cygwin, bitvisessh, and winrm as part of the initial setup that uses the floppy disk. This'll be a real bitch to refactor...

Right now the only way to pass variables to any of these floppy scripts is by directly modifying _packer_config.cmd. 6 years ago when Packer was created, this and typing stuff with the boot_command was pretty much the only way to do things. Nowadays though, you can directly influence the provisioners using environment variables which can also be influenced w/ user variables. So, I do think that this is a step in the right direction. Plus having access to a local http server is pretty handy too.

So...If I do end up creating a PR to do this sort of thing :-(, I'll leave it up for people to pass judgement on because It'll really change a lot of things for the sake of fixing quirks like this and adding support for proxies.

A refactor of these floppy scripts will likely affect the following issues:

12 -- Updates will be installed during provisioning which would happen in a different order as the uac-enabling/disabling scripts aren't even included in the floppy_files for the templates. These can be easily configurable during provisioning using the environment.

124 -- Right now proxies will need to be configured by explicitly editting floppy/_packer_config.cmd. The author of PR #179 had to hack around this by copying the scripts around and running them later. We can also make this with user-configurable variables similar to the way that chef-bento does things.

173 -- I'm still not sure why we're hardcoding a password here when we can already auth with a user. This can be easily looked into.