Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

How to provide answer file? #13

Open
JVimes opened this issue Nov 1, 2014 · 11 comments
Open

How to provide answer file? #13

JVimes opened this issue Nov 1, 2014 · 11 comments

Comments

@JVimes
Copy link

JVimes commented Nov 1, 2014

Is there a way to reference an answer file in the json so that it will be mounted/used at install time? If not, that'd be nice.

@pbolduc
Copy link

pbolduc commented Nov 1, 2014

In my fork, you do it the same way as the virtualbox builder.

{
  "vm_name": "win2008-standard",
  "type": "hyperv-iso",
  "guest_os_type": "windows7srv-64",
  "iso_url": "{{ user `iso_url` }}",
  "iso_checksum": "{{ user `iso_checksum` }}",
  "iso_checksum_type": "sha1",
  "floppy_files": [
    "floppy/win2008-standard/Autounattend.xml",
    "floppy/00-run-all-scripts.cmd",
    "floppy/install-winrm.cmd",
    "floppy/powerconfig.bat",
    "floppy/01-install-wget.cmd",
    "floppy/_download.cmd",
    "floppy/_packer_config.cmd",
    "floppy/passwordchange.bat",
    "floppy/openssh.bat",
    "floppy/zz-start-sshd.cmd"
  ],
  "disk_size_gb": 40,
  "wait_time_minutes": 10,
  "ram_size_mb": 1024
},

I have added a new step,

&common.StepCreateFloppy{ Files: b.config.FloppyFiles },

and removed the mounting of the embedded floppy image for Server 2012 R2. You can add any file to the floppy as long as it fits in the 1.44MB. I have plans to extend provisioner so that I can install things like windows updates via [Windows Updates Offline(http://download.wsusoffline.net/), Visual Studio, SQL Server, etc.

@JVimes
Copy link
Author

JVimes commented Nov 1, 2014

That's great, thanks! If it's stable, that needs to get pulled in :)
About the provisioning, aren't those already handled by the supported Packer provisioners? I guess I haven't done much with them yet (doing that later, in Vagrant), so maybe there's something I don't know.

@pbolduc
Copy link

pbolduc commented Nov 1, 2014

I am not sure about the provisioners either. It could do what I want already. Basically, I need to be able to specify the iso file to mount and then a command to run to do the silent install.

On my fork, I have created some goals that I want to accomplish by forking. I would be interested in other people's use cases. For example, I am only interested in running stuff against the local Hyper-V instance. Others may want to provision against a remote hyper-v server. I would be interested in anything special you are looking to do.

@JVimes
Copy link
Author

JVimes commented Nov 1, 2014

Easy ISO mounting would be nice. There's a cmdlet in PowerShell 4.0 (some OS's would have update), but it's not mounting it using the VM technology, you'd have to make it visible within the VM using a shared folder, etc.

I tried your fork with configuration like that in your comment, and got "Unknown configuration key" on floppy_files and a few others. Have the latest changes been pushed? Or is the bin directory old, perhaps? The sample json in bin looks stock. I've never built .go files before. Is there a project file to start from?

I'm trying to build a vagrant box to run a build. I'd like to run it locally in Hyper-V while I'm authoring it, and occasionally for special purposes. Later, it'll run on a server although probably not in Hyper-V. At my last job, we had a couple build VMs running on a Hyper-V server, though.

@pbolduc
Copy link

pbolduc commented Nov 1, 2014

I just updated in plugin in the bin directory and the config file sample. I have been testing against a Windows Server 2008 install. I am also using a fork of box-cutter/windows-vm. To run it, copy the plugin to the packer bin directory. I use a batch file to kick off VM build. There are a number of known issues still:

  • still wait's 10 minutes for install to complete
  • doesn't detect properly when to auto install is completed
  • I have to kill the packer process after the OS is installed due to above

Here is an example:

E:\work\packer\windows-vm>type pack-it-2008.cmd

SETLOCAL

PATH=C:\tools\packer-0.7.1;%PATH%

SET HYPERV_BUILDER=hyperv-iso
SET PACKER_VARS=
SET ISO_URL=F:\my-msdn\operating-systems\windows-server-2008\en_windows_server_2008_datacenter_enterprise_standard_sp2_x86_dvd_342333.iso
SET ISO_CHECKSUM=

packer build -only=%HYPERV_BUILDER% %PACKER_VARS% -var "iso_url=%ISO_URL%" -var "iso_checksum=%ISO_CHECKSUM%" win2008-standard.json

E:\work\packer\windows-vm>pack-it-2008.cmd

E:\work\packer\windows-vm>packer build -only=hyperv-iso  -var "iso_url=F:\my-msdn\operating-systems\windows-server-2008\en_windows_server_2008_datacenter_enterprise_standard_sp2_x86_dvd_342333.iso" -var "iso_checksum=" win2008-standard.json
hyperv-iso output will be in this color.

Warnings for build 'hyperv-iso':

* Hyper-V might fail to create a VM if there is no available memory in the system.

==> hyperv-iso: Creating temporary directory...
==> hyperv-iso: Creating floppy disk...
    hyperv-iso: Copying: floppy/win2008-standard/Autounattend.xml
    hyperv-iso: Copying: floppy/00-run-all-scripts.cmd
    hyperv-iso: Copying: floppy/install-winrm.cmd
    hyperv-iso: Copying: floppy/powerconfig.bat
    hyperv-iso: Copying: floppy/01-install-wget.cmd
    hyperv-iso: Copying: floppy/_download.cmd
    hyperv-iso: Copying: floppy/_packer_config.cmd
    hyperv-iso: Copying: floppy/passwordchange.bat
    hyperv-iso: Copying: floppy/openssh.bat
    hyperv-iso: Copying: floppy/zz-start-sshd.cmd
==> hyperv-iso: Creating Internal switch...
==> hyperv-iso: Creating virtual machine...
==> hyperv-iso: Enabling Integration Service...
==> hyperv-iso: Mounting dvd drive...
==> hyperv-iso: Mounting floppy drive...
==> hyperv-iso: Starting vm...
==> hyperv-iso: Installing! Waiting for 10 minutes to let the action to complete...

@pbolduc
Copy link

pbolduc commented Nov 1, 2014

We should move this conversation to my repo.

@JVimes
Copy link
Author

JVimes commented Nov 2, 2014

Good plan. I would, but there's no "Issues" section ;) Not sure where else to post. I'm not seeing the latest commit. Did it get pushed?

@pbolduc
Copy link

pbolduc commented Nov 2, 2014

Added Issues to my project.

@joyce7216
Copy link

Thanks, pbolduc, really helpful !!

@Tiberriver256
Copy link

Old issue but did this ever get pulled in?

@pbolduc
Copy link

pbolduc commented Aug 20, 2016

The correct place to look is hashicorp/packer#2576 there has been extensive work done on the hyper-v builder.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants