packer-windows
packer-windows copied to clipboard
add Packer template for Windows XP
This is an attempt to create a Packer template for Windows XP, and open WinRM for provisioners. Work in Progress
WinRM requires DotNet 2.0. I had to add wget in the floppy to download the necessary files after the initial installation is done.
At this point, WinRM is installed and I'm calling a setup_winrm.bat
script to open it, but somehow Packer cannot connect to it :/
If anyone is interest and can give me some help, i would appreciate !
Thanks.
Wow. What is the use case for that? I mean, other than collecting packer templates ;-) Edit: OK your profile gives me some tips why someone wants to build XP in 2008. It's still alive.
When I started with Packer years ago I also thought about Win XP, but never found a way to do this.
Instead of using wget, what about some built-in tools (maybe bitsadmin.exe, or other things described eg. in https://stackoverflow.com/questions/4619088/windows-batch-file-file-download-from-a-url)
I thought it was out of support until I found this...
😨
@StefanScherer Wow. What is the use case for that? I mean, other than collecting packer templates ;-)
Let's say i'm an archaeologist :) And for the sake of completeness !
Instead of using wget, what about some built-in tools (maybe bitsadmin.exe, or other things described eg. in https://stackoverflow.com/questions/4619088/windows-batch-file-file-download-from-a-url)
The thing is that there is no Powershell 2.0
in Windows XP ...
So you need to download something to give you powershell.
I tried many things to download files natively, even VBscript: https://github.com/Wenzel/packer-templates-winxp/blob/3f606178602090258d2ba6d1e400a0a8b358a450/scripts/download_dotnet2.0.vbs
' Set your settings
strFileURL = "https://download.microsoft.com/download/0/8/c/08c19fa4-4c4f-4ffb-9d6c-150906578c9e/NetFx20SP1_x86.exe"
strHDLocation = "c:\temp\dotnet.exe"
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
End if
But it always failed.
And as i'm not a VBScript expert, i prefered to just add the wget
binary.
But if you can figure out how to use this bitsadmin
, go for it =)
I wonder how a Packer template with Win95 will look with this inside.
@lmayorga1980
Seems like it's possible ! https://www.youtube.com/watch?v=BfWw8ALGCQ0
I just looked into my MSDN downloads and found some XP downloads with type "CDR" - I had to think what this could be. Wow, we were able install operating systems from CD-ROM 😆
I gave it some minutes and added the vmware-iso section. But my problem is that I don't see a network card in the VM. VMware Fusion tells me that the e1000 network card is present.
When i tested with Qemu, i had internet access after the installation.
Is it not the case for you on vmware ?
I made some progress since last time. First, WinRM was not opened because of an Access Denied issue.
This has been solved by disabling the forceguest
key.
see this forum for more information.
Now WinRM is opened, but misconfigured.
When packer tries to connect, it returns 401 - invalid content type
Any ideas ? We are close ! Thanks !
Wow! Maybe something like this https://github.com/masterzen/winrm/issues/75, there also is a link to a blog post by Matt Wrock.
hi @StefanScherer , thanks for the link.
I tested my winrm setup script on a dedicated VM, and attempted a connection with PyWinRM:
so this winrm script is not working only in the context of packer. Maybe it's a bug in the packer winrm code ?
This PR is fantastic! @sneal can you summon the WinRM gods?
@joefitzgerald i actually found the issue. The problem does not come from WinRM, but Windows XP.
It turns out that the WINNT.sif
configuration that i provided will setup an account named Administrator
with the vagrant
password, and not vagrant/vagrant
as i expected.
Therefore the WinRM error is totally correct !
Right now i'm trying to tweak the autounattend file to setup an admin vagrant/vagrant
account :)
I have my first successful build of this packer template on QEMU ! :tada:
WinRM connection is working.
Looking at this forum, it seems that setting the user accounts are the responsability of another file oobeinfo.inf
You don't create user accounts with WinNT.sif - that would be done either with oobeinfo.inf, or the NET command (put in to a batch command file).
So let's not go too complicated for this PR.
TODO:
- [ ] debug
vmware-iso
networking (ping @StefanScherer ) - [ ] what should we do with the product key/iso name ? find a trial iso of WinXP from MSDN ?? Can we leave the product key in the repo as long as we don't provide the ISO ?
Thanks @Wenzel for all the hard work. I'll try to find some time to test again with vmware-iso soon.
The product key from MSDN shouldn't be added.
What we need in general would be this https://github.com/hashicorp/packer/issues/4530 to be able to insert variables into static floppy files. That would help all Windows Packer templates.
@StefanScherer, from what I can tell from folks who have worked with Packer before, like in mwrock/packer-templates, the pattern to use to prep files is to use some external tool to template the files before a run and then run your packer command. For example, if you want to parameterize an autounattend.xml file you would put some unique string in the file as a parameter, "{{ user windowsKey
}}" and replace it: (Get-Content $file) -replace "{{ *user
windowsKey *}}", $windowsKey
@StefanScherer I removed the product key from WINNT.SIF
and cleared the template.
What's the next step for this PR ?
(Sorry i forgot that it was still opened :) )