Commit 06730010 authored by Stefan Scherer's avatar Stefan Scherer
Browse files

Switch to WinRM, install docker automatically

parent 45db7603
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend"> <unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE"> <settings pass="windowsPE">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SetupUILanguage> <SetupUILanguage>
<UILanguage>en-US</UILanguage> <UILanguage>en-US</UILanguage>
</SetupUILanguage> </SetupUILanguage>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<UILanguageFallback>en-US</UILanguageFallback> <UILanguageFallback>en-US</UILanguageFallback>
<UserLocale>de-DE</UserLocale> <UserLocale>de-DE</UserLocale>
</component> </component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DiskConfiguration> <DiskConfiguration>
<Disk wcm:action="add"> <Disk wcm:action="add">
<CreatePartitions> <CreatePartitions>
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<!-- Do not uncomment the Key element if you are using trial ISOs --> <!-- Do not uncomment the Key element if you are using trial ISOs -->
<!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs --> <!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs -->
<!--<Key>D2N9P-3P6X9-2R39C-7RTCD-MDVJX</Key>--> <!--<Key>D2N9P-3P6X9-2R39C-7RTCD-MDVJX</Key>-->
<WillShowUI>Never</WillShowUI> <WillShowUI>OnError</WillShowUI>
</ProductKey> </ProductKey>
<AcceptEula>true</AcceptEula> <AcceptEula>true</AcceptEula>
<FullName>Vagrant</FullName> <FullName>Vagrant</FullName>
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</component> </component>
</settings> </settings>
<settings pass="specialize"> <settings pass="specialize">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OEMInformation> <OEMInformation>
<HelpCustomized>false</HelpCustomized> <HelpCustomized>false</HelpCustomized>
</OEMInformation> </OEMInformation>
...@@ -83,22 +83,41 @@ ...@@ -83,22 +83,41 @@
<TimeZone>W. Europe Standard Time</TimeZone> <TimeZone>W. Europe Standard Time</TimeZone>
<RegisteredOwner/> <RegisteredOwner/>
</component> </component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon> <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
</component> </component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<IEHardenAdmin>false</IEHardenAdmin> <IEHardenAdmin>false</IEHardenAdmin>
<IEHardenUser>false</IEHardenUser> <IEHardenUser>false</IEHardenUser>
</component> </component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon> <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
</component> </component>
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipAutoActivation>true</SkipAutoActivation> <SkipAutoActivation>true</SkipAutoActivation>
</component> </component>
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>1</Order>
<Description>Set Execution Policy 64 Bit</Description>
<Path>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Order>2</Order>
<Description>Set Execution Policy 32 Bit</Description>
<Path>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Order>3</Order>
<Description>Disable WinRM</Description>
<Path>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\disable-winrm.ps1</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
</settings> </settings>
<settings pass="oobeSystem"> <settings pass="oobeSystem">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AutoLogon> <AutoLogon>
<Password> <Password>
<Value>vagrant</Value> <Value>vagrant</Value>
...@@ -121,125 +140,52 @@ ...@@ -121,125 +140,52 @@
<RequiresUserInput>true</RequiresUserInput> <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine> <CommandLine>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\disable-winrm.ps1</CommandLine>
<Description>winrm quickconfig -q</Description> <Description>Disable WinRM</Description>
<Order>3</Order> <Order>3</Order>
<RequiresUserInput>true</RequiresUserInput> <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm quickconfig -transport:http</CommandLine>
<Description>winrm quickconfig -transport:http</Description>
<Order>4</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}</CommandLine>
<Description>Win RM MaxTimoutms</Description>
<Order>5</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="800"}</CommandLine>
<Description>Win RM MaxMemoryPerShellMB</Description>
<Order>6</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine>
<Description>Win RM AllowUnencrypted</Description>
<Order>7</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}</CommandLine>
<Description>Win RM auth Basic</Description>
<Order>8</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}</CommandLine>
<Description>Win RM client auth Basic</Description>
<Order>9</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} </CommandLine>
<Description>Win RM listener Address/Port</Description>
<Order>10</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes </CommandLine>
<Description>Win RM adv firewall enable</Description>
<Order>11</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985" </CommandLine>
<Description>Win RM port open</Description>
<Order>12</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c net stop winrm </CommandLine>
<Description>Stop Win RM Service </Description>
<Order>13</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c sc config winrm start= auto</CommandLine>
<Description>Win RM Autostart</Description>
<Order>14</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c net start winrm</CommandLine>
<Description>Start Win RM Service</Description>
<Order>15</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine> <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine>
<Order>16</Order> <Order>4</Order>
<Description>Show file extensions in Explorer</Description> <Description>Show file extensions in Explorer</Description>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f</CommandLine> <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f</CommandLine>
<Order>17</Order> <Order>5</Order>
<Description>Enable QuickEdit mode</Description> <Description>Enable QuickEdit mode</Description>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f</CommandLine> <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f</CommandLine>
<Order>18</Order> <Order>6</Order>
<Description>Show Run command in Start Menu</Description> <Description>Show Run command in Start Menu</Description>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f</CommandLine> <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f</CommandLine>
<Order>19</Order> <Order>7</Order>
<Description>Show Administrative Tools in Start Menu</Description> <Description>Show Administrative Tools in Start Menu</Description>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f</CommandLine> <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f</CommandLine>
<Order>20</Order> <Order>8</Order>
<Description>Zero Hibernation File</Description> <Description>Zero Hibernation File</Description>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f</CommandLine> <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f</CommandLine>
<Order>21</Order> <Order>9</Order>
<Description>Disable Hibernation Mode</Description> <Description>Disable Hibernation Mode</Description>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE</CommandLine> <CommandLine>cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE</CommandLine>
<Order>22</Order> <Order>10</Order>
<Description>Disable password expiration for vagrant user</Description> <Description>Disable password expiration for vagrant user</Description>
</SynchronousCommand> </SynchronousCommand>
<!-- WITHOUT WINDOWS UPDATES --> <!-- WITHOUT WINDOWS UPDATES -->
<!-- <!--
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 -AutoStart</CommandLine> <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\enable-winrm.ps1</CommandLine>
<Description>Install OpenSSH</Description> <Description>Enable WinRM</Description>
<Order>99</Order> <Order>99</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand> </SynchronousCommand>
--> -->
<!-- END WITHOUT WINDOWS UPDATES --> <!-- END WITHOUT WINDOWS UPDATES -->
...@@ -284,13 +230,13 @@ ...@@ -284,13 +230,13 @@
</LocalAccount> </LocalAccount>
</LocalAccounts> </LocalAccounts>
</UserAccounts> </UserAccounts>
<RegisteredOwner/> <RegisteredOwner />
</component> </component>
</settings> </settings>
<settings pass="offlineServicing"> <settings pass="offlineServicing">
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EnableLUA>false</EnableLUA> <EnableLUA>false</EnableLUA>
</component> </component>
</settings> </settings>
<cpi:offlineImage xmlns:cpi="urn:schemas-microsoft-com:cpi" cpi:source="wim:c:/wim/install.wim#Windows Server 2016 SERVERSTANDARD"/> <cpi:offlineImage cpi:source="wim:c:/wim/install.wim#Windows Server 2012 R2 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend> </unattend>
Enable-PSRemoting -Force
winrm quickconfig -q
winrm quickconfig -transport:http
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="800"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set winrm/config/client/auth '@{Basic="true"}'
winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}'
# Set-Service winrm -startuptype "auto"
# Restart-Service winrm
Write-Host "Install Containers"
Install-WindowsFeature -Name Containers
Write-Host "Install Hyper-V"
Install-WindowsFeature -Name Hyper-V
Stop-Service winrm
. sc.exe config winrm start= delayed-auto
Sleep 30
netsh advfirewall firewall set rule group="Windows Remote Administration" new enable=yes
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow
Restart-Computer
powershell.exe -Command "Install-WindowsFeature -Name Containers"
powershell.exe -Command "Install-WindowsFeature -Name Hyper-V"
shutdown /r /t 5 /f /d p:4:1 /c "Reboot for Containters"
net stop winrm
net stop OpenSSHd
echo Sleeping while restart in progress
ping 127.0.0.1 -n 60 > nul
rem https://msdn.microsoft.com/virtualization/windowscontainers/quick_start/inplace_setup
powershell.exe -Command "wget -uri https://aka.ms/tp4/Install-ContainerHost -OutFile C:\Install-ContainerHost-1.ps1"
rem patch the install script, see https://github.com/Microsoft/Virtualization-Documentation/pull/90
powershell.exe -Command "cat C:\Install-ContainerHost-1.ps1 | %%{$_ -replace 'qfe =','qfe = 0 #'} | Set-Content C:\Install-ContainerHost.ps1"
powershell.exe -File "C:\Install-ContainerHost.ps1" -HyperV
echo Done with %0
rem https://msdn.microsoft.com/virtualization/windowscontainers/quick_start/manage_docker
Set-Service winrm -startuptype "auto"
# https://msdn.microsoft.com/virtualization/windowscontainers/quick_start/inplace_setup
wget -uri https://aka.ms/tp4/Install-ContainerHost -OutFile C:\Install-ContainerHost-1.ps1
# patch the install script, see https://github.com/Microsoft/Virtualization-Documentation/pull/90
cat C:\Install-ContainerHost-1.ps1 | %{$_ -replace 'qfe =','qfe = 0 #'} | Set-Content C:\Install-ContainerHost.ps1
# create a Task Scheduler task which is also able to run in battery mode due
# to host notebooks working in battery mode. This complicates the whole script
# from a one liner to a fat XML - good heaven.
function Run-Interactive {
param( [string] $commandline)
$xml = @"
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2014-03-27T13:53:05</Date>
<Author>vagrant</Author>
</RegistrationInfo>
<Triggers>
<TimeTrigger>
<StartBoundary>2014-03-27T00:00:00</StartBoundary>
<Enabled>true</Enabled>
</TimeTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>vagrant</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>powershell.exe</Command>
<Arguments>-Command $commandline</Arguments>
</Exec>
</Actions>
</Task>
"@
$XmlFile = $env:Temp + "\InstallContainerHost.xml"
Write-Host "Write Task '$commandline' to $XmlFile"
$xml | Out-File $XmlFile
& schtasks /Delete /F /TN InstallContainerHost
& schtasks /Create /TN InstallContainerHost /XML $XmlFile
& schtasks /Run /TN InstallContainerHost
Write-Host "Waiting until Scheduled Task InstallContainerHost task is no longer running"
do {
Start-Sleep -Seconds 5
} while ( (& schtasks /query /tn InstallContainerHost | Select-String -Pattern "InstallContainerHost" -SimpleMatch) -like "*Running*")
if ((& schtasks /query /tn InstallContainerHost | Select-String -Pattern "InstallContainerHost" -SimpleMatch) -like "*Could not start*") {
Write-Error "Scheduled Task InstallContainerHost could not start!"
} else {
Write-Host "Scheduled Task InstallContainerHost '$commandline' finished"
}
& schtasks /Delete /F /TN InstallContainerHost
}
Run-Interactive -commandline "C:\Install-ContainerHost.ps1 -HyperV"
Run-Interactive -commandline "C:\Install-ContainerHost.ps1 -h"
# https://msdn.microsoft.com/virtualization/windowscontainers/quick_start/manage_docker
echo Set WinRM start type to auto
sc config winrm start= auto
...@@ -2,26 +2,27 @@ ...@@ -2,26 +2,27 @@
"builders": [ "builders": [
{ {
"type": "vmware-iso", "type": "vmware-iso",
"communicator": "winrm",
"iso_url": "https://aka.ms/tp4/serveriso", "iso_url": "https://aka.ms/tp4/serveriso",
"iso_checksum_type": "md5", "iso_checksum_type": "md5",
"iso_checksum": "935ba77651210bd1bd71a114c92b0caa", "iso_checksum": "935ba77651210bd1bd71a114c92b0caa",
"headless": false, "headless": false,
"boot_wait": "6m", "boot_wait": "6m",
"boot_command": [ "<tab><enter>" ], "boot_command": [ "<tab><enter>" ],
"ssh_username": "vagrant", "winrm_username": "vagrant",
"ssh_password": "vagrant", "winrm_password": "vagrant",
"ssh_wait_timeout": "6h", "winrm_timeout": "6h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "windows8srv-64", "guest_os_type": "windows8srv-64",
"tools_upload_flavor": "windows",
"disk_size": 61440, "disk_size": 61440,
"vnc_port_min": 5900, "vnc_port_min": 5900,
"vnc_port_max": 5980, "vnc_port_max": 5980,
"floppy_files": [ "floppy_files": [
"./answer_files/2016/Autounattend.xml", "./answer_files/2016/Autounattend.xml",
"./scripts/disable-winrm.ps1",
"./scripts/2016/enable-winrm.ps1",
"./scripts/microsoft-updates.bat", "./scripts/microsoft-updates.bat",
"./scripts/win-updates.ps1", "./scripts/win-updates.ps1"
"./scripts/openssh.ps1"
], ],
"vmx_data": { "vmx_data": {
"RemoteDisplay.vnc.enabled": "false", "RemoteDisplay.vnc.enabled": "false",
...@@ -35,22 +36,26 @@ ...@@ -35,22 +36,26 @@
}, },
{ {
"type": "virtualbox-iso", "type": "virtualbox-iso",
"communicator": "winrm",
"iso_url": "https://aka.ms/tp4/serveriso", "iso_url": "https://aka.ms/tp4/serveriso",
"iso_checksum_type": "md5", "iso_checksum_type": "md5",
"iso_checksum": "935ba77651210bd1bd71a114c92b0caa", "iso_checksum": "935ba77651210bd1bd71a114c92b0caa",
"headless": false, "headless": false,
"boot_wait": "2m", "boot_wait": "6m",
"ssh_username": "vagrant", "boot_command": [ "<tab><enter>" ],
"ssh_password": "vagrant", "winrm_username": "vagrant",
"ssh_wait_timeout": "6h", "winrm_password": "vagrant",
"winrm_timeout": "6h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "Windows2012_64", "guest_os_type": "Windows2012_64",
"guest_additions_mode": "disable",
"disk_size": 61440, "disk_size": 61440,
"floppy_files": [ "floppy_files": [
"./answer_files/2016/Autounattend.xml", "./answer_files/2016/Autounattend.xml",
"./scripts/disable-winrm.ps1",
"./scripts/2016/enable-winrm.ps1",
"./scripts/microsoft-updates.bat", "./scripts/microsoft-updates.bat",
"./scripts/win-updates.ps1", "./scripts/win-updates.ps1",
"./scripts/openssh.ps1",
"./scripts/oracle-cert.cer" "./scripts/oracle-cert.cer"
], ],
"vboxmanage": [ "vboxmanage": [
...@@ -71,24 +76,29 @@ ...@@ -71,24 +76,29 @@
], ],
"provisioners": [ "provisioners": [
{ {
"type": "shell", "type": "windows-shell",
"remote_path": "/tmp/script.bat", "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [ "scripts": [
"./scripts/set-winrm-automatic.bat",
"./scripts/vm-guest-tools.bat", "./scripts/vm-guest-tools.bat",
"./scripts/vagrant-ssh.bat", "./scripts/enable-rdp.bat"
"./scripts/enable-rdp.bat", ]
"./scripts/install-containers.bat", },
"./scripts/sleep.bat", {
"type": "windows-restart"
},
{
"type": "windows-shell",
"execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"",
"scripts": [
"./scripts/wait-for-uplink.bat", "./scripts/wait-for-uplink.bat",
"./scripts/install-docker.bat",
"./scripts/uac-enable.bat" "./scripts/uac-enable.bat"
] ]
}, },
{ {
"type": "shell", "type": "powershell",
"inline": [ "scripts": [
"rm -rf /tmp/*" "./scripts/install-docker.ps1"
] ]
} }
], ],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment