Giter Club home page Giter Club logo

packer-windows10's Introduction

Packer-Windows10

A Packer build to make a pretty vanilla Windows 10 x64 box for use with VMWare Desktop or Virtualbox.

This project is just a clone of my other Windows Packer project with some very minor changes. Eventually the two projects will merge and form like Voltron.

In essence, the build does the following:

  • Use an existing, vanilla, Windows 10 x64 Enterprise trial ISO
  • Enable WinRM (in a slightly scary, Unauthenticated mode, for Packer/Vagrant to use)
  • Create a vagrant user (as is the style)
  • Grab all the Windows updates is can
  • Install VM guest additions
  • Turn off Hibernation
  • Turn on RDP
  • Set the network type for the virtual adapter to 'Home' and not bug you about it
  • Turns autologin off because I like simulating end user environments, ok?

Requirements

This project works great with Virtualbox, so don't bother shelling out for VMWare Fusion without trying VirtualBox first.

Usage

This guide will assume you zero knowledge of any or all of these systems.

  1. Install Vagrant.
  2. Install Packer - these instructions help.
  3. Download and install Virtualbox or VMWare Fusion/Workstation (with the Vagrant Plugin).
  4. Ensure you have an RDP client (you do if you're running Windows) - for Mac, install this
  5. Download the Windows 10 x64 Enterprise Trial, save the ISO someplace you'll remember.
  6. Make a working directory somewhere (OSX suggestion mkdir ~/Packer_Projects/) and cd to that directory (e.g. cd ~/Packer_Projects/).
  7. Clone this repo to your working directory: git clone https://github.com/luciusbono/Packer-Windows10 (if you don't have git installed: here are instructions.
  8. Determine the MD5 hash of your iso: md5 [path to iso] in OSX FCIV -md5 [path to iso] in Windows (download it here) -- Linux people are smarter than me and likely can just calculate the md5 hash through ether-magic.
  9. To actually build your VM, build against the hypervisor target you're interested in:
  • For Virtualbox run packer build -only=virtualbox-iso -var 'iso_path=[path to iso]' -var 'iso_md5=[md5 of iso]' packer.json
  • For VMWare Fusion/Workstation run packer build -only=vmware-iso -var 'iso_path=[path to iso]' -var 'iso_md5=[md5 of iso]' packer.json.
  • For Parallels run packer build -only=parallels-iso -var 'iso_path=[path to iso]' -var 'iso_md5=[md5 of iso]' packer.json
  • for HyperV run packer build -only=hyperv-iso -var 'iso_path=[path to iso]' -var 'iso_md5=[md5 of iso]' packer.json optionally, if you want to specify a different HyperV virtual switch other than "Default Switch" you can specify it in the switch_name var.
  1. You will see build pause on Waiting for WinRM to become available - this is normal! If you actually access the console session on your VM you will see that it is getting updates from Microsoft's servers. This can easily take 30 minutes, so be patient. After the updates are all installed, Windows will turn it's WinRM service back on and Packer will continue with the build.
  2. Run vagrant box add --name [vagrant box name] [name of .box file]. The name can be anything you want. For example, this command is valid for Virtualbox: vagrant box add --name windows10 virtualbox-iso_windows-10.box
  3. Make a working directory for your Vagrant VM (OSX suggestion mkdir ~/Vagrant_Projects/windows10) and cd to that directory (e.g. cd ~/Vagrant_Projects/windows10)
  4. Type vagrant init [vagrant box name] - for example vagrant init windows10
  5. Type vagrant up and once the box has been launched type vagrant rdp
  6. Continue through any certificate errors and login with the username: vagrant and the password: vagrant
  7. Feel free to delete the .box file that packer created. You may also delete your .iso you downloaded if you wish.
  8. Stop the box by typing vagrant halt. Destroy the box by typing vagrant destroy

Usage Explanation

The packer.json file requires two variables to validate. You can confirm these with a packer inspect packer.json

$ packer inspect packer.json 
  iso_md5     =
  iso_path    =
  switch_name = Default Switch

Builders:

  hyperv-iso
  parallels-iso
  virtualbox-iso
  vmware-iso

Provisioners:

  powershell
  windows-restart

Since there are two Builders, you also likely want to specify one or the other.

Valid options are virtualbox-iso or vmware-iso.

The other two variables, iso_md5 and iso_path, are the path and the MD5 hash of the Windows 10 Enterprise trial ISO.

Other things to note

Update script

The update grabbing script is a bit of a grey-box, as I basically just hijacked it (as well as lots of other code) from this awesome project - which I think is the defacto standard for Windows / Packer relations - but I wanted a leaner build. This project started as a frankenstein build, but is turning more into a ground-up rewrite of a lot of other projects' scripts and code. With the exception of the update-windows.ps1 script, which I only modified very slightly, I will slowly go through all the code in this project and make sure I kill all the cruft.

If you have multiple hypervisors installed

If, for some reason, you have multiple hypervisors, but want to run this project in Virtualbox, for example, you need to specify the provider in your vagrant up statement like so: vagrant up --provider=virtualbox

Almost nobody will fall into the camp, but it's worth mentioning. Have fun!

Sym links are off by default for synced folders

The vagrantfile template disables the SharedFoldersEnableSymlinksCreate option. I'd rather default to an untrusted guest since most of my workflows do not require symlinks. To change this, just add config.vm.synced_folder ".", "/vagrant", SharedFoldersEnableSymlinksCreate: true to your vagrantfile and do a vagrant reload.

Troubleshooting

vagrant rdp prompts for login credentials but vagrant/vagrant does not work

I ran into this issue on a Windows 10 host with this project. I submitted an issue. The resolution is to choose Use another account and login with .\vagrant as the login and vagrant as the password. Unforuntately, it appears that one must log in with these credentials in this manner each time you vagrant rdp (unless that issue says otherwise...).

vagrant rdp -- /public will also force mstsc into "public mode" which will clear the credentials dialogs each time.

packer-windows10's People

Contributors

gildas avatar luciusbono avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-windows10's Issues

Action Center: You Must Restart Your Computer ...

screen shot 2017-03-13 at 4 16 00 pm

This message is BS, since UAC is re-enabled (it needs to be off during the build). There does not appear to be any way to programmatically clear notifications from the Action Center, and I've already tried throwing in extra restarts for good measure, so I may look into disabling the Action Center until the build is nearly complete and UAC comes back on again.

Updates Take Incredibly Long

Grabbing Windows updates takes an inordinately long amount of time for some reason, which can result in the build timing out and not creating an artifact. Just leaving this here as a placeholder.

Process hanging waiting for network confirmation

I kicked things off following the steps on the README, and when I got to Waiting for WinRM to become available, I let it sit for a while, expecting a long wait for updates, as described.

4 hours later, no appreciable progress. I opened up VirtualBox and hit Show, and it turns out it was hung up waiting on user input. It showed the network I was on and was waiting to select the Next button. I manually hit the button and let it go, and it went along through downloading and installing updates, rebooting, etc.

It looks like it might need a tweak to get past this step? I don't know PowerShell so I am at a loss as to offering up a PR. I am currently on wifi at work, and there's multiple possible networks, so that perhaps is a difference that you might not be experiencing?

  • Using MacOS 10.14.1 Mojave
  • Packer version 1.3.2
  • Vagrant version 2.2.2
  • Oracle VirtualBox version 5.2.22

is it supposed to work?

Came back to your project as I looked into building Windows VMs on my local VirtualBox.
I remember a working build from a few months ago, today a new run simply didn't proceed for hours.

Maybe something is broken?

# packer.log
2022/06/20 14:09:33 packer-builder-virtualbox-iso plugin: [DEBUG] connecting to remote shell using WinRM
2022/06/20 14:10:48 packer-builder-virtualbox-iso plugin: [ERROR] connection error: unknown error Post "http://127.0.0.1:3013/wsman": read tcp 127.0.0.1:59980->127.0.0.1:3013: read: connection reset by peer
2022/06/20 14:10:48 packer-builder-virtualbox-iso plugin: [ERROR] WinRM connection err: unknown error Post "http://127.0.0.1:3013/wsman": read tcp 127.0.0.1:59980->127.0.0.1:3013: read: connection reset by peer

To me it looks as if the VM does nothing, watching traffic graphs on my router there seemed to be no downloads or so.

No urgency here, just curious.

ah, btw: packer-1.8.1 on Fedora 36, VirtualBox 6.1.34

Issue: update-windows.ps1 not cleaning up after itself

update-windows.ps1 is supposed to clean up after itself after it's done updating by removing the key InstallWindowsUpdates at HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

Because this key is left behind, a Powershell prompt appears when Windows boots for a moment, fails to execute anything, and closes.

Timeout for WinRM

Ran the script overnight, and both vmware-iso and virtualbox-iso timed out waiting for WinRM.

c:\vagrant share inaccessible

It appears that even though the VirtualBox guest tools get properly installed during the Packer build, and that they set u p the c:\vagrant share back to the host machine, the share is inaccessible. The fix is to re-install the Guest Tools, which is annoying.

I've seen reports of this being a problem because of a Windows Update, which should not be the case with our build since all the updates happen BEFORE the installation of the Guest Tools. I will try putting the Guest Tools installer later in the build and see if that helps anything.

Support HyperV Gen 1 VMs

I need to start supporting HyperV, since running Docker on Windows is a pain if you've got another Hypervisor.

Generation 2 VMs would require a separate autounattend.xml file, I believe, because they'd have to use UEFI and generation 2 VMs don't support virtual floppy disks, so a whole crazy dance where I'd have to build an ISO with the autounattend.xml file and the rest of the scripts in the build would have to happen.

I also suspect that a Generation 2 VM might be worse for certain types of client testing, as it may "aware it's a VM" which could change how some software behaves. More research required.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.