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

Commit

Permalink
Merge branch 'release/v1.24'
Browse files Browse the repository at this point in the history
* release/v1.24: (28 commits)
  Updated changelog
  Update Autounattend.xml
  Updated changelog
  Update Ultradefrag to 6.1.0
  update to Windows 10 Inside Preview Build 10074
  use Write-Output
  install setupssh-6.7p1-2.exe
  remove ssh_host_ed25519_key as Vagrant's net-ssh 2.9.1 does not support it
  update to setupssh-6.6.1p1-3
  Stop SearchResult display failing
  Display windows updates that have been installed
  Define MaxUpdatesPerCycle for updates on 2008 R2 builds
  Windows 10 Technical Preview Build 9926
  Updated changelog with fixed issues
  Fixing product key URL in comment.
  Fixing cut-and-paste error from 2012 autounattend.
  Add support for Hyper-V Server 2012 R2
  extend primary partition to use template.json
  updated to setupssh-6.7p1-1.exe
  Grammar
  ...
  • Loading branch information
StefanScherer committed Jun 8, 2015
2 parents 5c602a7 + 8d79753 commit 6360234
Show file tree
Hide file tree
Showing 15 changed files with 881 additions and 28 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## Unreleased

## v1.24 (June 8th, 2015)

* Clarified use of the `<Key>` element in Windows 8.1 autounattend file (#114)
* Fixed issue with OpenSSH / Packer race condition (#113)
* Fixed issue with Windows 8.1 product key and computer name (#121)
* Fixed issue where disk size would always be 60GB regardless of value in packer template (#117)
* Added Windows 10 Technical Preview (#132, #144)
* Fixed Windows Updates for Windows 2008 R2 builds (#135)
* Display Windows Updates that have been installed (#139)
* Added support for Hyper-V Server 2012 R2 (#120)
* Updated OpenSSH to 6.7 (#111)
* Updated Ultadefrag to 6.1.0 (#145)
* Fixed ComputerName for Windows 7 build (#125)

## v1.23 (Nov 5th, 2014)

* Resolved issue with Windows 7 not successfully completing an update run (#83)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ If you have serious objections to OpenSSH being installed, you can always add an
* Create a Vagrantfile, use the base box from Packer, connect to the VM via WinRM (using the [vagrant-windows](https://github.com/WinRb/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
Expand Down
288 changes: 288 additions & 0 deletions answer_files/10/Autounattend.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions answer_files/2008_r2/Autounattend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Size>60000</Size>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
Expand Down Expand Up @@ -248,7 +248,7 @@
<Description>Enable Microsoft Updates</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1</CommandLine>
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1 -MaxUpdatesPerCycle 30</CommandLine>
<Description>Install Windows Updates</Description>
<Order>100</Order>
<RequiresUserInput>true</RequiresUserInput>
Expand Down
2 changes: 1 addition & 1 deletion answer_files/2008_r2_core/Autounattend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Size>60000</Size>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
Expand Down
2 changes: 1 addition & 1 deletion answer_files/2012/Autounattend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Size>60000</Size>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
Expand Down
296 changes: 296 additions & 0 deletions answer_files/2012_r2_hyperv/Autounattend.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion answer_files/7/Autounattend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Size>60000</Size>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
Expand Down
22 changes: 18 additions & 4 deletions answer_files/81/Autounattend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Size>60000</Size>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
Expand All @@ -31,8 +31,22 @@
<AcceptEula>true</AcceptEula>
<FullName>Vagrant Administrator</FullName>
<Organization>Vagrant Inc.</Organization>
<!-- Product Key from http://technet.microsoft.com/en-us/library/ff793406.aspx -->
<ProductKey>XC9B7-NBPP2-83J2H-RHMBY-92BT4

<!--
NOTE: If you are re-configuring this for use of a retail key
and using a retail ISO, you need to adjust the <ProductKey> block
below to look like this:
<ProductKey>
<Key>33PXH-7Y6KF-2VJC9-XBBR8-HVTHH</Key>
<WillShowUI>Never</WillShowUI>
</ProductKey>
Notice the addition of the `<Key>` element.
-->

<!-- Product Key from http://technet.microsoft.com/en-us/library/jj612867.aspx -->
<ProductKey>MHF9N-XY6XB-WVXMC-BTDCT-MKKG7
<WillShowUI>Never</WillShowUI>
</ProductKey>
</UserData>
Expand Down Expand Up @@ -262,7 +276,7 @@
<HelpCustomized>false</HelpCustomized>
</OEMInformation>
<!-- Rename computer here. -->
<ComputerName>vagrant-2012</ComputerName>
<ComputerName>vagrant-81</ComputerName>
<TimeZone>Pacific Standard Time</TimeZone>
<RegisteredOwner/>
</component>
Expand Down
6 changes: 3 additions & 3 deletions scripts/compact.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ if not exist "C:\Windows\Temp\7z920-x64.msi" (
msiexec /qb /i C:\Windows\Temp\7z920-x64.msi

if not exist "C:\Windows\Temp\ultradefrag.zip" (
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/ultradefrag/ultradefrag-portable-6.0.2.bin.amd64.zip', 'C:\Windows\Temp\ultradefrag.zip')" <NUL
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/ultradefrag/ultradefrag-portable-6.1.0.bin.amd64.zip', 'C:\Windows\Temp\ultradefrag.zip')" <NUL
)

if not exist "C:\Windows\Temp\ultradefrag-portable-6.0.2.amd64\udefrag.exe" (
if not exist "C:\Windows\Temp\ultradefrag-portable-6.1.0.amd64\udefrag.exe" (
cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\ultradefrag.zip -oC:\Windows\Temp"
)

Expand All @@ -26,7 +26,7 @@ rmdir /S /Q C:\Windows\SoftwareDistribution\Download
mkdir C:\Windows\SoftwareDistribution\Download
net start wuauserv

cmd /c C:\Windows\Temp\ultradefrag-portable-6.0.2.amd64\udefrag.exe --optimize --repeat C:
cmd /c C:\Windows\Temp\ultradefrag-portable-6.1.0.amd64\udefrag.exe --optimize --repeat C:

cmd /c %SystemRoot%\System32\reg.exe ADD HKCU\Software\Sysinternals\SDelete /v EulaAccepted /t REG_DWORD /d 1 /f
cmd /c C:\Windows\Temp\sdelete.exe -q -z C:
35 changes: 20 additions & 15 deletions scripts/openssh.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,31 @@ param (
[switch]$AutoStart = $false
)

Write-Host "AutoStart: $AutoStart"
Write-Output "AutoStart: $AutoStart"
$is_64bit = [IntPtr]::size -eq 8

# setup openssh
$ssh_download_url = "http://www.mls-software.com/files/setupssh-6.6p1-1.exe"
if ($is_64bit) {
Write-Host "64 bit OS found"
$ssh_download_url = "http://www.mls-software.com/files/setupssh-6.6p1-1(x64).exe"
}
$ssh_download_url = "http://www.mls-software.com/files/setupssh-6.7p1-2.exe"

if (!(Test-Path "C:\Program Files\OpenSSH\bin\ssh.exe")) {
Write-Host "Downloading $ssh_download_url"
Write-Output "Downloading $ssh_download_url"
(New-Object System.Net.WebClient).DownloadFile($ssh_download_url, "C:\Windows\Temp\openssh.exe")
Start-Process "C:\Windows\Temp\openssh.exe" "/S /port=22 /privsep=1 /password=D@rj33l1ng" -NoNewWindow -Wait

# initially set the port to 2222 so that there is not a race
# condition in which packer connects to SSH before we can disable the service
Start-Process "C:\Windows\Temp\openssh.exe" "/S /port=2222 /privsep=1 /password=D@rj33l1ng" -NoNewWindow -Wait
}

Stop-Service "OpenSSHd" -Force

# ensure vagrant can log in
Write-Host "Setting vagrant user file permissions"
Write-Output "Setting vagrant user file permissions"
New-Item -ItemType Directory -Force -Path "C:\Users\vagrant\.ssh"
C:\Windows\System32\icacls.exe "C:\Users\vagrant" /grant "vagrant:(OI)(CI)F"
C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\bin" /grant "vagrant:(OI)RX"
C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\usr\sbin" /grant "vagrant:(OI)RX"

Write-Host "Setting SSH home directories"
Write-Output "Setting SSH home directories"
(Get-Content "C:\Program Files\OpenSSH\etc\passwd") |
Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } |
Set-Content 'C:\Program Files\OpenSSH\etc\passwd'
Expand All @@ -38,7 +37,7 @@ $passwd_file = $passwd_file -replace '/bin/bash', '/bin/sh'
Set-Content 'C:\Program Files\OpenSSH\etc\passwd' $passwd_file

# fix opensshd to not be strict
Write-Host "Setting OpenSSH to be non-strict"
Write-Output "Setting OpenSSH to be non-strict"
$sshd_config = Get-Content "C:\Program Files\OpenSSH\etc\sshd_config"
$sshd_config = $sshd_config -replace 'StrictModes yes', 'StrictModes no'
$sshd_config = $sshd_config -replace '#PubkeyAuthentication yes', 'PubkeyAuthentication yes'
Expand All @@ -47,16 +46,22 @@ $sshd_config = $sshd_config -replace '#PermitUserEnvironment no', 'PermitUserEnv
$sshd_config = $sshd_config -replace '#UseDNS yes', 'UseDNS no'
# disable the login banner
$sshd_config = $sshd_config -replace 'Banner /etc/banner.txt', '#Banner /etc/banner.txt'
# next time OpenSSH starts have it listen on th eproper port
$sshd_config = $sshd_config -replace 'Port 2222', "Port 22"
Set-Content "C:\Program Files\OpenSSH\etc\sshd_config" $sshd_config

Write-Output "Removing ed25519 key as Vagrant net-ssh 2.9.1 does not support it"
Remove-Item -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\etc\ssh_host_ed25519_key"
Remove-Item -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\etc\ssh_host_ed25519_key.pub"

# use c:\Windows\Temp as /tmp location
Write-Host "Setting temp directory location"
Write-Output "Setting temp directory location"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\tmp"
C:\Program` Files\OpenSSH\bin\junction.exe /accepteula "C:\Program Files\OpenSSH\tmp" "C:\Windows\Temp"
C:\Windows\System32\icacls.exe "C:\Windows\Temp" /grant "vagrant:(OI)(CI)F"

# add 64 bit environment variables missing from SSH
Write-Host "Setting SSH environment"
Write-Output "Setting SSH environment"
$sshenv = "TEMP=C:\Windows\Temp"
if ($is_64bit) {
$env_vars = "ProgramFiles(x86)=C:\Program Files (x86)", `
Expand All @@ -68,11 +73,11 @@ if ($is_64bit) {
Set-Content C:\Users\vagrant\.ssh\environment $sshenv

# record the path for provisioners (without the newline)
Write-Host "Recording PATH for provisioners"
Write-Output "Recording PATH for provisioners"
Set-Content C:\Windows\Temp\PATH ([byte[]][char[]] $env:PATH) -Encoding Byte

# configure firewall
Write-Host "Configuring firewall"
Write-Output "Configuring firewall"
netsh advfirewall firewall add rule name="SSHD" dir=in action=allow service=OpenSSHd enable=yes
netsh advfirewall firewall add rule name="SSHD" dir=in action=allow program="C:\Program Files\OpenSSH\usr\sbin\sshd.exe" enable=yes
netsh advfirewall firewall add rule name="ssh" dir=in action=allow protocol=TCP localport=22
Expand Down
9 changes: 8 additions & 1 deletion scripts/win-updates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ function Install-WindowsUpdates() {
Title = $UpdatesToInstall.Item($i).Title
Result = $InstallationResult.GetUpdateResult($i).ResultCode
}
LogWrite "Item: " $UpdatesToInstall.Item($i).Title
LogWrite "Result: " $InstallationResult.GetUpdateResult($i).ResultCode;
}

Check-ContinueRestartOrEnd
Expand Down Expand Up @@ -190,7 +192,12 @@ function Check-WindowsUpdates() {
$Message = "There are " + $SearchResult.Updates.Count + " more updates."
LogWrite $Message
try {
$script:SearchResult.Updates |Select-Object -Property Title, Description, SupportUrl, UninstallationNotes, RebootRequired, EulaAccepted |Format-List
for($i=0; $i -lt $script:SearchResult.Updates.Count; $i++) {
LogWrite $script:SearchResult.Updates.Item($i).Title
LogWrite $script:SearchResult.Updates.Item($i).Description
LogWrite $script:SearchResult.Updates.Item($i).RebootRequired
LogWrite $script:SearchResult.Updates.Item($i).EulaAccepted
}
$global:MoreUpdates=1
} catch {
LogWrite $_.Exception | Format-List -force
Expand Down
47 changes: 47 additions & 0 deletions vagrantfile-windows_10.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.require_version ">= 1.6.2"

Vagrant.configure("2") do |config|
config.vm.define "vagrant-windows-10-preview"
config.vm.box = "windows_10_preview"
config.vm.communicator = "winrm"

# Admin user name and password
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"

config.vm.guest = :windows
config.windows.halt_timeout = 15

config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true
config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true

config.vm.provider :virtualbox do |v, override|
#v.gui = true
v.customize ["modifyvm", :id, "--memory", 2048]
v.customize ["modifyvm", :id, "--cpus", 2]
v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
end

config.vm.provider :vmware_fusion do |v, override|
#v.gui = true
v.vmx["memsize"] = "2048"
v.vmx["numvcpus"] = "2"
v.vmx["ethernet0.virtualDev"] = "vmxnet3"
v.vmx["RemoteDisplay.vnc.enabled"] = "false"
v.vmx["RemoteDisplay.vnc.port"] = "5900"
v.vmx["scsi0.virtualDev"] = "lsisas1068"
end

config.vm.provider :vmware_workstation do |v, override|
#v.gui = true
v.vmx["memsize"] = "2048"
v.vmx["numvcpus"] = "2"
v.vmx["ethernet0.virtualDev"] = "vmxnet3"
v.vmx["RemoteDisplay.vnc.enabled"] = "false"
v.vmx["RemoteDisplay.vnc.port"] = "5900"
v.vmx["scsi0.virtualDev"] = "lsisas1068"
end
end
77 changes: 77 additions & 0 deletions windows_10.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"builders": [
{
"type": "vmware-iso",
"iso_url": "http://iso.esd.microsoft.com/W10IP/E0F85BFCD0F6BA607BF1528926371D21F8F6B6BF/Windows10_InsiderPreview_x64_EN-US_10074.iso",
"iso_checksum_type": "sha1",
"iso_checksum": "E354B44994B46FB7CDC295FA1F075D9F95FECEA8",
"headless": false,
"boot_wait": "2m",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "2h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "windows8srv-64",
"tools_upload_flavor": "windows",
"disk_size": 61440,
"vnc_port_min": 5900,
"vnc_port_max": 5980,
"floppy_files": [
"./answer_files/10/Autounattend.xml",
"./scripts/microsoft-updates.bat",
"./scripts/win-updates.ps1",
"./scripts/openssh.ps1"
],
"vmx_data": {
"RemoteDisplay.vnc.enabled": "false",
"RemoteDisplay.vnc.port": "5900",
"memsize": "2048",
"numvcpus": "2",
"scsi0.virtualDev": "lsisas1068"
}
},
{
"type": "virtualbox-iso",
"iso_url": "http://iso.esd.microsoft.com/W10IP/E0F85BFCD0F6BA607BF1528926371D21F8F6B6BF/Windows10_InsiderPreview_x64_EN-US_10074.iso",
"iso_checksum_type": "sha1",
"iso_checksum": "E354B44994B46FB7CDC295FA1F075D9F95FECEA8",
"headless": false,
"boot_wait": "2m",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "2h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "Windows81_64",
"disk_size": 61440,
"floppy_files": [
"./answer_files/10/Autounattend.xml",
"./scripts/microsoft-updates.bat",
"./scripts/win-updates.ps1",
"./scripts/openssh.ps1",
"./scripts/oracle-cert.cer"
],
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--memory",
"2048"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"2"
]
]
}
],
"post-processors": [
{
"type": "vagrant",
"keep_input_artifact": false,
"output": "windows_10_{{.Provider}}.box",
"vagrantfile_template": "vagrantfile-windows_10.template"
}
]
}
Loading

0 comments on commit 6360234

Please sign in to comment.