Giter Club home page Giter Club logo

packer-windows's Introduction

Windows Templates for Packer

Introduction

This repository contains Windows templates that can be used to create boxes for Vagrant using Packer (Website) (Github).

This repo began by borrowing bits from the VeeWee Windows templates (https://github.com/jedi4ever/veewee/tree/master/templates). Modifications were made to work with Packer and the VMware Fusion / VirtualBox providers for Packer and Vagrant.

Packer Version

Packer 0.5.1 or greater is required.

Windows Versions

The following Windows versions are known to work (built with VMware Fusion 6.0.4 and VirtualBox 4.3.12):

  • Windows 2012 R2
  • Windows 2012 R2 Core
  • Windows 2012
  • Windows 2008 R2
  • Windows 2008 R2 Core
  • Windows 10
  • Windows 8.1
  • Windows 7

Windows Editions

All Windows Server versions are defaulted to the Server Standard edition. You can modify this by editing the Autounattend.xml file, changing the ImageInstall>OSImage>InstallFrom>MetaData>Value element (e.g. to Windows Server 2012 R2 SERVERDATACENTER).

Product Keys

The Autounattend.xml files are configured to work correctly with trial ISOs (which will be downloaded and cached for you the first time you perform a packer build). If you would like to use retail or volume license ISOs, you need to update the UserData>ProductKey element as follows:

  • Uncomment the <Key>...</Key> element
  • Insert your product key into the Key element

If you are going to configure your VM as a KMS client, you can use the product keys at http://technet.microsoft.com/en-us/library/jj612867.aspx. These are the default values used in the Key element.

Windows Updates

The scripts in this repo will install all Windows updates – by default – during Windows Setup. This is a very time consuming process, depending on the age of the OS and the quantity of updates released since the last service pack. You might want to do yourself a favor during development and disable this functionality, by commenting out the WITH WINDOWS UPDATES section and uncommenting the WITHOUT WINDOWS UPDATES section in Autounattend.xml:

<!-- WITHOUT WINDOWS UPDATES -->
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 -AutoStart</CommandLine>
    <Description>Install OpenSSH</Description>
    <Order>99</Order>
    <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<!-- END WITHOUT WINDOWS UPDATES -->
<!-- WITH WINDOWS UPDATES -->
<!--
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c a:\microsoft-updates.bat</CommandLine>
    <Order>98</Order>
    <Description>Enable Microsoft Updates</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1</CommandLine>
    <Description>Install OpenSSH</Description>
    <Order>99</Order>
    <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1</CommandLine>
    <Description>Install Windows Updates</Description>
    <Order>100</Order>
    <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
-->
<!-- END WITH WINDOWS UPDATES -->

Doing so will give you hours back in your day, which is a good thing.

OpenSSH / WinRM

Currently, Packer has a single communicator that uses SSH. This means we need an SSH server installed on Windows - which is not optimal as we could use WinRM to communicate with the Windows VM. In the short term, everything works well with SSH; in the medium term, work is underway on a WinRM communicator for Packer.

If you have serious objections to OpenSSH being installed, you can always add another stage to your build pipeline:

  • Build a base box using Packer
  • Create a Vagrantfile, use the base box from Packer, connect to the VM via WinRM (using the vagrant-windows plugin) and disable the 'sshd' service or uninstall OpenSSH completely
  • Perform a Vagrant run and output a .box file

It's worth mentioning that many Chef cookbooks will not work properly through Cygwin's SSH environment on Windows. Specifically, packages that need access to environment-specific configurations such as the PATH variable, will fail. This includes packages that use the Windows installer, msiexec.exe.

It's currently recommended that you add a second step to your pipeline and use Vagrant to install your packages through Chef.

Using .box Files With Vagrant

The generated box files include a Vagrantfile template that is suitable for use with Vagrant 1.6.2+, which includes native support for Windows and uses WinRM to communicate with the box.

Getting Started

Trial versions of Windows 2008 R2 / 2012 / 2012 R2 / 2016 are used by default. These images can be used for 180 days without activation.

Alternatively – if you have access to MSDN or TechNet – you can download retail or volume license ISO images and place them in the iso directory. If you do, you should supply appropriate values for iso_url (e.g. ./iso/<path to your iso>.iso) and iso_checksum (e.g. <the md5 of your iso>) to the Packer command. For example, to use the Windows 2008 R2 (With SP1) retail ISO:

  1. Download the Windows Server 2008 R2 with Service Pack 1 (x64) - DVD (English) ISO (en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso)

  2. Verify that en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso has an MD5 hash of 8dcde01d0da526100869e2457aafb7ca (Microsoft lists a SHA1 hash of d3fd7bf85ee1d5bdd72de5b2c69a7b470733cd0a, which is equivalent)

  3. Clone this repo to a local directory

  4. Move en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso to the iso directory

  5. Run:

    packer build \
        -var iso_url=./iso/en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso \
        -var iso_checksum=8dcde01d0da526100869e2457aafb7ca windows_2008_r2.json
    

Variables

The Packer templates support the following variables:

Name Description
iso_url Path or URL to ISO file
iso_checksum Checksum (see also iso_checksum_type) of the ISO file
iso_checksum_type The checksum algorithm to use (out of those supported by Packer)
autounattend Path to the Autounattend.xml file

Contributing

Pull requests welcomed.

Acknowledgements

CloudBees is providing a hosted Jenkins master through their CloudBees FOSS program. We also use their On-Premise Executor feature to connect a physical Mac Mini Server running VMware Fusion.

Powered By CloudBeesBuilt On DEV@Cloud

packer-windows's People

Contributors

bigwave avatar bmolz avatar brettporter avatar chappoo avatar ctfhacker avatar dglinder avatar dtcroley avatar dylanmei avatar emyl avatar ferhaty avatar flauschbaellchen avatar gadgetmg avatar jbarber avatar jcoutch avatar jdub avatar joefitzgerald avatar jvimes avatar kensykora avatar krlmlr avatar mewm avatar mozgiii avatar rgl avatar ryanjarv avatar senglin avatar sherbang avatar sneal avatar stefanscherer avatar stonith avatar thebigbear avatar wenzel 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  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

packer-windows's Issues

oracle Cer is out of date

I dont ahve time for a pull but for virtualbox vm-guest tools i would change the code to this.

:virtualbox

move /Y C:\Users\vagrant\VBoxGuestAdditions.iso C:\Windows\Temp

cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\VBoxGuestAdditions.iso -oC:\Windows\Temp\virtualbox"
:: There needs to be Oracle CA (Certificate Authority) certificates installed in order
:: to prevent user intervention popups which will undermine a silent installation.
cmd /c C:\Windows\Temp\virtualbox\cert\VBoxCertUtil add-trusted-publisher C:\Windows\Temp\virtualbox\cert\oracle-vbox.cer --root C:\Windows\Temp\virtualbox\cert\oracle-vbox.cer
cmd /c C:\Windows\Temp\virtualbox\VBoxWindowsAdditions.exe /S
goto :done

it will register the cer file taht came with the iso and not the one in your a dirve... this fixes the install failure of the guest tools... i think the cer changes in 4.3.10 and above.

Chocolatey on Windows 7 - Fails to install chocopacks

I have been trying to test a developer machine set up - so switched off Windows updates via the AutoUnattend.xml file. I then added the chocolatey.bat and chocopacks.bat files to the provisioners section of the build (using virtualbox-iso). I am now facing an issue that the Chocolatey elevated permissions as part of the install takes a long time and then the chocopacks.bat file fails as it states the box is not connected.

I assume I am using the Chocolatey scripts as they were intended - or are these intended as Vagrant provisioning scripts rather than Packer scripts? I turned of the Windows updates to enable me to test the provisioning scripts based on the basebox faster. I had previously had success with the Window updates turned on.

I am continuing to investigate the problem I am having, but if anyone has any pointers/ideas that would be much appracited.

RDP Disabled for vagrant user

RDP is disabled for the user 'vagrant' so running the command 'vagrant rdp' fails.

Work Around

Poweroff the VM in VirtualBox and then start it from VirtualBox, this will allow you to use the Windows interface to change the RDP settings for the Vagrant user and allow RDP access.

Force Run .Net Runtime Optimization Service before boxing

Since I have to work on other stuff today, I'm dropping in notes for a few issues I'm planning on working on over the next week or so, but someone else can feel free to jump in and let me know if they're not great ideas or not:

Each time the box starts up from a fresh init, the .NET runtime optimization service pegs the CPU for what seems like 10-15 minutes which is a background task with low priority that compiles/optimizes the .Net framework for the current CPU type. This process can and should be forced to complete before the box is packaged up so that users don't have to deal with the CPU pegs on fresh init's.

http://support.microsoft.com/kb/2570538

Creating vmx file to deploy onto vSphere

Hi, I'm quite happy to be able to use packer to build Windows images thanks to this project. I want to deploy VMs (actually, VM templates are my end goal) onto a vSphere instance, but haven't managed it yet.

I have modified the packer configuration, adding '"keep_input_artifact": true' to the vagrant builder, and tried running ovftool on the .vmx file that gets created in the output directory.

But ovftool fails because it has a path to floppy0, which doesn't exist.

Error message:

Error: File (/var/folders/zl/57c1vmr532z_ryf1scw53_b9ycmxh7/T/packer964492999) could not be found.

From the .vmx file:

floppy0.filename = "/var/folders/zl/57c1vmr532z_ryf1scw53_b9ycmxh7/T/packer964492999"
floppy0.filetype = "file"
floppy0.present = "TRUE"

So I'm not sure if there's a way to generate the .vmx file without the floppy drive - presumably, once the OS has been installed and we don't need the Autounattend.xml file anymore, it can be detached.

Is there a change needed to the config file to make this work, or something else I could do? I could post-process the .vmx file to disable the drive, but it feels like a hack. Either I'm doing something wrong, or there's an improvement to be made somewhere.

Thanks,
Kief

Works perfectly on OS X but fails on windows with access denied errors on .vmem

This happens after almost all steps of installation are done, and chef script is run.

'vmware-iso' errored: remove output-vmware-iso\564dfbe7-d762-be2a-1600-9b769835764e.vmem: Access is denied

Tried powershell, but the result remains the same. Any clues?

I am using a fork with my own JSON for windows embedded 8.1, which is practically windows 8.1.

Generate Packer JSON Files

Picking up the conversation where we left off in Dylan's pull request: #1 .

I think there are a few dimensions that are required for a minimally useful packer-windows template:

  • Operating System Version
    • Windows 7
    • Windows 2008 R2
    • Windows 8
    • Windows 2012
    • Windows 8.1
    • Windows 2012 R2
  • Operating System Edition
    • Desktop
      • Windows 7
        • Starter
        • Home Basic
        • Home Professional
        • Professional
        • Enterprise
        • Ultimate
      • Windows 8
        • Windows 8
        • Pro
        • Enterprise
    • Server
      • Standard
      • Enterprise
      • Datacenter
  • Builder
    • VMware
    • VirtualBox
    • Others
  • Provisioners
    • Script
    • PowerShell
    • Chef
    • Puppet
    • Other

If we could provide some level of reuse at each level (OS Version, OS Edition, Builder, Provisioner), that would hopefully drastically reduce the number of distinct .json files we manage (because we can generate them).

I agree with Shawn that we need to maintain the ability to customize, which could be achieved via the build process, or by providing hooks for extensibility (e.g. if user defined script x exists, run it after the core provisioning steps). Also, there's nothing stopping someone from taking a .json file we generate and then customizing it from there.

Does that make sense? Do you think I'm missing any obvious requirements?

[improvement] user variables for puppet/chef versions (opensource/enterprise)

What do you think about having some user env variables to set the puppet release/version for the provisioning.

"variables": {
    "vagrant_user": "vagrant",
    "vagrant_password": "vagrant",
    "puppet_release": "PUPPET_RELEASE=OPEN",
    "puppet_version": "PUPPET_VERSION=3.6.1"
    },
  ...

    "provisioners": [{
    "type": "shell",
    "environment_vars": [ "{{user `puppet_release`}}",
                          "{{user `puppet_version`}}"
                        ],
 ....

With this approach there will be no need to edit the puppet version in the .bat file

I guess having a lot of logic on the .bat file for the release and version would be a little dirty as well.

Just a though here.

Chef fails to install some packages if they depend on environment-specific conditions

This might be a well-known problem in the context of Windows boxes, but it took me a good long time debugging this before I realized exactly what the problem was and how to work around it.

As Packer currently only uses an SSH connector through Cygwin, Chef doesn't have a correct set of environment variables to work with for paths. Specifically, I was attempting to add the Chef package 7-zip and it repeated failed as it couldn't locate msiexec.exe.

If these results are accurate, I'm proposing additional documentation in the README so that future developers won't pull their hair out when Chef cookbooks like Git work properly, but other packages fail seemingly for no reason. I don't think it's worth trying to work around this issue outside of just recommending that developers add a second Vagrant step in their pipeline for configuring Chef cookbooks as Packer should receive proper WinRM support in the future.

I've attached my proposed edits to the readme in #102.

rundll32.exe runs high CPU usage

I noticed today on a fresh box I was spinning up was a runaway CPU issue taking up 50% of the CPU on an otherwise idle box. Task manager showed rundll32.exe at 50% cpu constantly (2-cpu VM). Using Process Explorer and a Stack Trace on the thread I get this:

ntoskrnl.exe!KeSynchronizeExecution+0x2246
ntoskrnl.exe!KeRemoveQueueEx+0x108e
ntoskrnl.exe!KeRemoveQueueEx+0xae9
ntoskrnl.exe!KeWaitForSingleObject+0x22a
ntoskrnl.exe!KeSetBasePriorityThread+0x4ec
ntoskrnl.exe!KeRemoveQueueEx+0x281d
ntoskrnl.exe!KeSynchronizeExecution+0x4133
msi.dll!MsiSetOfflineContextW+0x1254c0
msi.dll!MsiSetOfflineContextW+0x128829
msi.dll!MsiSetOfflineContextW+0x176f9e
msi.dll!MsiSetOfflineContextW+0x176e7d
msi.dll!MsiViewFetch+0xa9
aeinv.dll!UpdateSoftwareInventoryW+0x45245
aeinv.dll!UpdateSoftwareInventoryW+0x45578
aeinv.dll!UpdateSoftwareInventoryW+0x28e63
aeinv.dll!UpdateSoftwareInventoryW+0x27677
aeinv.dll!UpdateSoftwareInventoryW+0xedd4
aeinv.dll!UpdateSoftwareInventoryW+0xc812
aeinv.dll!UpdateSoftwareInventoryW+0xcce8
aeinv.dll!UpdateSoftwareInventoryW+0xcb70
aeinv.dll!CreateSoftwareInventory+0x43b
aepdu.dll!AePduRunUpdateW+0x2fb3
aepdu.dll!AePduRunUpdateW+0x109e
aepdu.dll!AePduRunUpdateW+0x1a39
aepdu.dll!AePduRunUpdateW+0x24d0
aepdu.dll!AePduRunUpdateW+0xc5
rundll32.exe+0x249a
rundll32.exe+0x3e68
KERNEL32.DLL!BaseThreadInitThunk+0xd
ntdll.dll!RtlUserThreadStart+0x1d

Googling for aeinv.dll reveals that it's part of the Microsoft Application Experience program, which I'm pretty sure you can opt out of. Opening up server manager confirms this (Local Server / Customer Experience Improvement Program - Participating)

I killed the runaway task in task manager and it didn't start back up -- I'm not sure if this confirms what I'm thinking is the issue or not, but I think it'd be best to setup the box to build defaults and opt out of the customer experience program.

Issues with chef_client

I've spent quite a bit of time trying to debug chef_client issues. Oddly, if I run the batch files or commands directly via ssh vagrant@host they always work. However, the packer provisioner will fail whenever chef_client shells out. I've tried running chef_client as a scheduled task, but now I'm running into the same thing with schtasks where packer doesn't seem to have permissions yet when running the commands directly works without issues. Any thoughts? I'm thinking of trying to switch to a full cygwin install.

Anyone successfully uninstall openssh?

Trying to uninstall openssh remotely, has anyone been able to do so? It seems to run but doesn't actually complete. However, running it in a UI session works without issues with "c:\program files\openssh\uninstall.exe" /S. I think it has to do with the uninstaller creating new cmd processes to execute things.

Script not copied to floppy for windows 7,8

The latest changes added a call to microsoft-updates.bat in the Autounattend.xml for all the systems, but it is only placed on the floppy image for the server OSs, not for windows 7 or 8.
Which is correct - copy it to the floppy for all the systems or remove it from the Autounattend.xml for windows 7 and 8?

Problems invoking puppet-masterless after using scripts/puppet.bat

What I'm trying to do is repurpose the windows_2008_r2.json file by swapping out scripts/chef.bat for scripts/puppet.bat and then calling out to puppet-masterless to install and run my manifests.

The scripts/puppet.bat file is being executed and puppet is being installed correctly. However, once puppet apply is invoked by puppet-masterless the execute_command is shown, but my manifest is not being executed and no additional output/errors are shown (even with PACKER_LOG=1 set).

For testing purposes, I have been using the following custom execute_command:

"execute_command": " \
    {{.FacterVars}}puppet apply \
        --debug \
        --logdest='C:/Windows/Temp/puppet-apply.log' \
        --modulepath='{{.ModulePath}}' \
        --manifestdir='{{.ManifestDir}}' \
        --detailed-exitcodes \
        -e 'include rubyinstaller' \
"

NOTES:

  • The spacing and EOL \s were added here for readability purposes only
  • I am using packer 0.5.2
  • When the execute_command "runs", the logdest file does not get created
  • I have even tried specifying the absolute path to puppet's bat file under Program Files just in case the guest OS PATH was not visible at the time puppet-masterless ran -- no effect
  • When I pause packer after the puppet-masterless step and I execute the generated execute_command at the guest Windows VM's command prompt, the execution works.
  • The (custom) "rubyinstaller" module that I'm using is attempting to install rubyinstaller in "verysilent" mode. Has anyone seen any limitations with puppet-masterless when using an installer on windows that requires a desktop?
  • I've also noticed on Windows with packer that if puppet apply fails or a shell script returns a non-zero ERRORLEVEL, packer keeps on going. Any suggestions on how to fail-fast? (EDIT: this bullet looks suspiciously like #45)
  • I only know this from the occasional warning that I'm seeing, but It appears that cygwin is being used under the covers by puppet-masterless. Any other gotchas I should keep in mind when working with custom execute_commands?

I realize that some of these questions may be best asked on the packer forum, but since these questions are very windows specific, I'm wondering if other trailblazers here have already encountered and resolved these issues.

[question] About vm-guest-tools.bat

On the following lines it seems that is looking for an env variable.(line 6 and 7)

if "%PACKER_BUILDER_TYPE%" equ "vmware" goto :vmware
if "%PACKER_BUILDER_TYPE%" equ "virtualbox" goto :virtualbox

Do i need to set this somewhere or as a environment variable before running packer build?

It doesn't seem to be executed.

==> virtualbox-iso: Provisioning with shell script: ./scripts/vm-guest-tools.bat
    virtualbox-iso:
    virtualbox-iso: C:\Users\vagrant>if not exist "C:\Windows\Temp\7z920-x64.msi" (powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/sevenzip/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')"  0<NUL )
    virtualbox-iso:
    virtualbox-iso: C:\Users\vagrant>msiexec /qb /i C:\Windows\Temp\7z920-x64.msi
    virtualbox-iso:
    virtualbox-iso: C:\Users\vagrant>if "virtualbox-iso" EQU "vmware" goto :vmware
    virtualbox-iso:
    virtualbox-iso: C:\Users\vagrant>if "virtualbox-iso" EQU "virtualbox" goto :virtualbox
    virtualbox-iso:
    virtualbox-iso: C:\Users\vagrant>goto :done
    virtualbox-iso:
    virtualbox-iso: C:\Users\vagrant>msiexec /qb /x C:\Windows\Temp\7z920-x64.msi
==> virtualbox-iso: Provisioning with shell script: ./scripts/puppet-enterprise.bat
    virtualbox-iso:

Waiting for SSH....Windows 7

When creating a Windows 7 box once all updates had been made the Waiting for SSH.... would just timeout. I stopped the box and restarted it to find that OpenSSH was disabled as a service.

Is the -Autostart flag that is used when not running windows updates (my SSH problem goes away at this time) needed for the windows update openssh command in the Autounattend.xml?

Provisioning fails because /tmp is not empty?

Right at the end of building a windows 7 VM packer failed with an error from what looks like an internally generated script.

This is Windows 7 building virtualbox. I'm on the latest versions of virtualbox, vagrant and packer. Everything has gone fine building the image (including all updates) and provisioning seems to have completed with the following scripts (all from the packer-windows project):

"./scripts/vm-guest-tools.bat",
"./scripts/enable-remote-desktop.bat",
"./scripts/vagrant-ssh.bat",
"./scripts/puppet.bat"

The console ouput ends with:
==> virtualbox-iso: Provisioning with shell script: ./scripts/puppet.bat
virtualbox-iso:
virtualbox-iso: C:\Users\vagrant>if not exist "C:\Windows\Temp\puppet.msi" (powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://downloads.puppetlabs.com/windows/puppet-3.5.1.msi', 'C:\Windows\Temp\puppet.msi')" 0<NUL )
virtualbox-iso:
virtualbox-iso: C:\Users\vagrant>msiexec /qn /i C:\Windows\Temp\puppet.msi /log C:\Windows\Temp\puppet.log
virtualbox-iso:
virtualbox-iso: C:\Users\vagrant>set /p ".=;C:\Program Files (x86)\Puppet Labs\Puppet\bin" 0<nul 1>>C:\Windows\Temp\PATH
virtualbox-iso:
virtualbox-iso: C:\Users\vagrant>set /p PATH= 0<C:\Windows\Temp\PATH
virtualbox-iso:
virtualbox-iso: C:\Users\vagrant>setx PATH "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Puppet Labs\Puppet\bin" /m
virtualbox-iso:
virtualbox-iso: SUCCESS: Specified value was saved.
==> virtualbox-iso: Provisioning with shell script: C:\Users\mbayliss\AppData\Local\Temp\packer-shell448994023
virtualbox-iso: rm: cannot remove `/tmp/TMP000000060D8C519E2AA75846': Device or resource busy
==> virtualbox-iso: Unregistering and deleting virtual machine...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Script exited with non-zero exit status: 1

Anybody seen this before? Any suggestions for a workaround?

Thanks,

Mike

SSH alternative to Cygwin

Regarding issue #3 comment by @sneal: In fact I'd rather not install Cygwin if I could.

I am having some success using OpenSSH for Windows 5.3 from coming from Chocolatey and also the 6.2 from mls-software.

The initial ssh handshake and scp operation to copy over .vbox_version work great but any subsequent scp operations blow up. I'm hoping it's something I can fix from the sshd configuration side, but it's strange how I can ssh and scp manually just fine but packer can't do more than one run against it. Investigation ongoing....

If there are similar ideas out there, I'd like to hear about it before I go too far down the rabbit hole.

Windows 7 64 sp1

Hi there, I attempting to use your packer templates for windows 7 64 sp1. I'm being stopped at the following command:

==> virtualbox: Typing the boot command...
==> virtualbox: Waiting for SSH to become available...

Eventually I get a SSH timeout. I've inspected the VM that was created and OpenSSH is installed.

Any ideas as to why packer doesn't see SSH?

Thanks for this project.

TDFord

Vagrant can't connect to produced boxes with VMWare Fusion

I'm trying to test out with Vagrant 1.6.2 features now since that code is added in, but I'm running into an odd issue that I'm not sure if it's an issue with Vagrant or the configuration of the Vagrantfile.

When I run vagrant up using the boxes produced the process stalls at the point where it's trying to connect via WinRM. Here's the output when running with info debug level:

Shell: powershell
Command: hostname
if ($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 0 }
Message: execution expired>
 INFO winrm: Checking whether WinRM is ready...
 INFO subprocess: Starting process: ["/Applications/VMware Fusion.app/Contents/Library/vmrun", "list"]
 INFO vmware_driver: Reading an accessible IP for machine...
 INFO vmware_driver: Reading VMX data...
 INFO vmware_driver: Reading DHCP lease for '00:0c:29:3d:ff:e0' on 'vmnet8'
 INFO vmware_driver: DHCP leases file: /var/db/vmware/vmnet-dhcpd-vmnet8.leases
 INFO dhcp_lease_file: Initialized DHCP helper: /var/db/vmware/vmnet-dhcpd-vmnet8.leases
 INFO dhcp_lease_file: Looking for IP for MAC: 00:0c:29:3d:ff:e0
 INFO dhcp_lease_file:   - IP: 192.168.125.161
 INFO provider: Execute capability: forwarded_ports [#<Vagrant::Machine: default (HashiCorp::VagrantVMwarefusion::Provider)>] (vmware_fusion)
 INFO winrmshell: Attempting to connect to WinRM...
 INFO winrmshell:   - Host: 192.168.125.161
 INFO winrmshell:   - Port: 55985
 INFO winrmshell:   - Username: vagrant
 INFO winrm: WinRM not up: #<VagrantPlugins::CommunicatorWinRM::Errors::ExecutionError: An error occurred executing a remote WinRM command.

Shell: powershell
Command: hostname
if ($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 0 }
Message: execution expired>
 INFO winrm: Checking whether WinRM is ready...
 INFO subprocess: Starting process: ["/Applications/VMware Fusion.app/Contents/Library/vmrun", "list"]
 INFO vmware_driver: Reading an accessible IP for machine...
 INFO vmware_driver: Reading VMX data...
 INFO vmware_driver: Reading DHCP lease for '00:0c:29:3d:ff:e0' on 'vmnet8'
 INFO vmware_driver: DHCP leases file: /var/db/vmware/vmnet-dhcpd-vmnet8.leases
 INFO dhcp_lease_file: Initialized DHCP helper: /var/db/vmware/vmnet-dhcpd-vmnet8.leases
 INFO dhcp_lease_file: Looking for IP for MAC: 00:0c:29:3d:ff:e0
 INFO dhcp_lease_file:   - IP: 192.168.125.161
 INFO provider: Execute capability: forwarded_ports [#<Vagrant::Machine: default (HashiCorp::VagrantVMwarefusion::Provider)>] (vmware_fusion)
 INFO winrmshell: Attempting to connect to WinRM...
 INFO winrmshell:   - Host: 192.168.125.161
 INFO winrmshell:   - Port: 55985
 INFO winrmshell:   - Username: vagrant

In this case, the 192.168.125.161 IP is the IP of the Guest OS, and as you can see it's trying to connect on port 55985 rather than 5985. I tried manually opening a connection to 5985 and the box is responding on that port, but I don't know how to change the port in the Vagrantfile or if it's even possible, and is just an issue with Vagrant.

Any ideas?

windows_2012_r2_core.json Produces Vagrant hang on "Waiting for the VM to finish booting"

Hi there,

I'm trying to build a Windows Server 2012 R2 Core image using packer. Packer completes successfully, and I get two .box files at the end which successfully boot, however vagrant up yields:

$ vagrant up
Bringing machine 'vagrant-windows-2012-r2-core' up with 'vmware_fusion' provider...
==> vagrant-windows-2012-r2-core: Cloning VMware VM: 'windows-2012-r2-core'. This can take some time...
==> vagrant-windows-2012-r2-core: Verifying vmnet devices are healthy...
==> vagrant-windows-2012-r2-core: Preparing network adapters...
==> vagrant-windows-2012-r2-core: Starting the VMware VM...
==> vagrant-windows-2012-r2-core: Waiting for the VM to finish booting...

It then just hangs forever. If I uncomment the v.gui = true line in the Vagrantfile I can see that it successfully boots and logs in as the vagrant user, it's just that vagrant doesn't seem to notice that this completed.

For the moment I'm going to go ahead and use the Windows 2012 R2 image (not Core) so I can keep moving, but does anyone have any experience as to why this wouldn't work?

I used the Vagrantfile template from the repo for 2012 R2 to spin it up with no modifications (other than renaming it from whatever.template and toggling the comment on v.gui as I mentioned above).

I'm on VMWare Fusion 5.0.5 and OS X 10.8.5 if that helps.

Windows 7 trial download URL no longer works?

Hoping this is just an intermittent issue at Microsoft.

Tried several times with packer and curling directly myself—Microsoft's server resets the connection soon after it starts.

curl -L http://care.dlservice.microsoft.com/dl/download/evalx/win7/x64/EN/7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso -o 7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0 2976M    0 27.0M    0     0  2228k      0  0:22:47  0:00:12  0:22:35 2066k
curl: (56) Recv failure: Connection reset by peer

Sometimes the openssh.bat errors and doesn't properly configure SSH

On rare occasions I've noticed a race condition between installing OpenSSH and configuring the files it installs:

  • C:\Program Files\OpenSSH\etc\passwd
  • C:\Program Files\OpenSSH\etc\sshd_config
  • C:\Users\vagrant.ssh\environment

Basically the batch file can error out with file not found errors.

Box still auto logs in on startup

After the image is boxed up, and a user init's and up's it, it continues to auto login on the vm console when it boots up. This is unnecessary and will use up some memory resources since running vagrant rdp will initiate a new desktop session. It'd be nice if we could remove the auto-login configuration before the box is packaged up.

How to install chocolatey packages

I have tried a couple of time to install chocolatey packages using .bat files. But I keep failing. I'm using package build windows_2012.json. And added an extra script like so :

"provisioners": [{
      "type": "shell",
      "remote_path": "/tmp/script.bat",
      "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
      "scripts": [
        "./scripts/vm-guest-tools.bat",
        "./scripts/chocolatey.bat",
        "./scripts/chocopacks.bat"
      ]
    }, {
      "type": "shell", "inline": ["rm -rf /tmp/*"]
  }]

The chocopacks.bat contains :

set /p PATH=<C:\Windows\Temp\PATH
cinst Dogtail.VisualStudio2012Ultimate
cinst nodejs.install
cinst GoogleChrome
cinst Firefox
cinst git.install
cinst Console2
cinst sublimetext2

Any tips on this would be very welcome!

Install RSync client to enable RSync file shares

Current configuration doesn't support rsync because the RSync client isn't installed in OpenSSH. I tested this out locally by copying the rsync.exe binary from http://mirrors.kernel.org/sourceware/cygwin/x86_64/release/rsync/ and dragged it into C:\Program Files\OpenSSH\bin on the guest (server 2012r2)

I then configured my vagrantfile to rsync a directory:

  config.vm.synced_folder '.', "/cygdrive/c/vagrant-rsync",
    type: "rsync",
    rsync__auto: "true",
    rsync__exclude: [".git/",".vagrant/"],
    id: "vagrant"

the /cygdrive/c/ was necessary to prevent vagrant from interpreting a warning as an error

After that, rsync folders worked on the guest OS with an OSX Host.

Clean install vmware-iso fails 2008-r2

Running packer build -only vmware-iso builds the machine but errors at the end with the following:

Build 'vmware-iso' errored: Error compacting disk: VMware error: VixDiskLib: Invalid configuration file parameter. Failed to read configuration file.
Failed to open the disk '/Users/jcastillo/Documents/Git/packer-windows/output-vmware-iso/disk.vmdk' : The specified virtual disk needs repair (0xe00003e86).
Failed to defragment: The specified virtual disk needs repair (0xe00003e86).

==> Some builds didn't complete successfully and had errors:
--> vmware-iso: Error compacting disk: VMware error: VixDiskLib: Invalid configuration file parameter. Failed to read configuration file.
Failed to open the disk '/Users/jcastillo/Documents/Git/packer-windows/output-vmware-iso/disk.vmdk' : The specified virtual disk needs repair (0xe00003e86).
Failed to defragment: The specified virtual disk needs repair (0xe00003e86).

The virtual box build does work.

windows_2008_r2.json builds a box that BSODs

When I build the packer template windows_2008_r2.json, it always builds successfully. However, when I try to run it with the corresponding vagrant file provided in the repo, I always get a BSOD. I'm using the .iso given in the packer template.

setting mac addr in template breaks on first run

Packer 0.5.1 add config.vm.base_mac = "{{ .BaseMacAddress }}" by default. Leaving this in the template breaks first vagrant up. Next time you run vagrant up this message vill disappear. This can be fixed by removing config.vm.base_mac = "{{ .BaseMacAddress }}" in the templates.

Windows doesn't wait for updates to finish before running custom provisioners

For a while now I've been unable to run the Windows 8.1 packer build with Windows Updates enabled and some additional custom provisioners (I'm using it to install Visual Studio etc).

This was successful prior to the upgrade of OpenSSL around the time of heartbleed, however. Is there some trick I've missed with having to swap the order of provisioners around to deal with reboots or similar?

SSH Starts before Windows Updates finish

I'm pretty sure this is an issue -- in the latest version the secure delete and defragger was running while windows updates was still doing its thing. In the latest version you updated SSH, this seems to open up SSH as soon as the install finishes?

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.