新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Assists with preparing a Windows VM prior to calling kubeadm join
|
||||
|
||||
.DESCRIPTION
|
||||
This script assists with joining a Windows node to a cluster.
|
||||
- Downloads Kubernetes binaries (kubelet, kubeadm) at the version specified
|
||||
- Registers wins as a service in order to run kube-proxy and cni as DaemonSets.
|
||||
- Registers kubelet as an nssm service. More info on nssm: https://nssm.cc/
|
||||
|
||||
.PARAMETER KubernetesVersion
|
||||
Kubernetes version to download and use
|
||||
|
||||
.EXAMPLE
|
||||
PS> .\PrepareNode.ps1 -KubernetesVersion v1.17.0
|
||||
|
||||
#>
|
||||
|
||||
Param(
|
||||
[parameter(Mandatory = $true, HelpMessage="Kubernetes version to use")]
|
||||
[string] $KubernetesVersion = 'v1.18.5'
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function DownloadFile($destination, $source) {
|
||||
Write-Host("Downloading $source to $destination")
|
||||
curl.exe --silent --fail -Lo $destination $source
|
||||
|
||||
if (!$?) {
|
||||
Write-Error "Download $source failed"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
if (!$KubernetesVersion.StartsWith("v")) {
|
||||
$KubernetesVersion = "v" + $KubernetesVersion
|
||||
}
|
||||
Write-Host "Using Kubernetes version: $KubernetesVersion"
|
||||
$global:Powershell = (Get-Command powershell).Source
|
||||
$global:PowershellArgs = "-ExecutionPolicy Bypass -NoProfile"
|
||||
$global:KubernetesPath = "$env:SystemDrive\k"
|
||||
$global:StartKubeletScript = "$global:KubernetesPath\StartKubelet.ps1"
|
||||
$global:NssmInstallDirectory = "$env:ProgramFiles\nssm"
|
||||
$kubeletBinPath = "$global:KubernetesPath\kubelet.exe"
|
||||
|
||||
mkdir -force "$global:KubernetesPath"
|
||||
$env:Path += ";$global:KubernetesPath"
|
||||
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
|
||||
|
||||
DownloadFile $kubeletBinPath https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubelet.exe
|
||||
DownloadFile "$global:KubernetesPath\kubeadm.exe" https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubeadm.exe
|
||||
DownloadFile "$global:KubernetesPath\wins.exe" https://github.com/rancher/wins/releases/download/v0.0.4/wins.exe
|
||||
|
||||
# Create host network to allow kubelet to schedule hostNetwork pods
|
||||
Write-Host "Creating Docker host network"
|
||||
docker network create -d nat host
|
||||
|
||||
Write-Host "Registering wins service"
|
||||
wins.exe srv app run --register
|
||||
start-service rancher-wins
|
||||
|
||||
mkdir -force C:\var\log\kubelet
|
||||
mkdir -force C:\var\lib\kubelet\etc\kubernetes
|
||||
mkdir -force C:\etc\kubernetes\pki
|
||||
New-Item -path C:\var\lib\kubelet\etc\kubernetes\pki -type SymbolicLink -value C:\etc\kubernetes\pki\
|
||||
|
||||
$StartKubeletFileContent = '$FileContent = Get-Content -Path "/var/lib/kubelet/kubeadm-flags.env"
|
||||
$global:KubeletArgs = $FileContent.Trim("KUBELET_KUBEADM_ARGS=`"")
|
||||
|
||||
$cmd = "C:\k\kubelet.exe $global:KubeletArgs --cert-dir=$env:SYSTEMDRIVE\var\lib\kubelet\pki --config=/var/lib/kubelet/config.yaml --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --hostname-override=$(hostname) --pod-infra-container-image=`"mcr.microsoft.com/k8s/core/pause:1.2.0`" --enable-debugging-handlers --cgroups-per-qos=false --enforce-node-allocatable=`"`" --network-plugin=cni --resolv-conf=`"`" --log-dir=/var/log/kubelet --logtostderr=false --image-pull-progress-deadline=20m"
|
||||
|
||||
Invoke-Expression $cmd'
|
||||
Set-Content -Path $global:StartKubeletScript -Value $StartKubeletFileContent
|
||||
|
||||
Write-Host "Installing nssm"
|
||||
$arch = "win32"
|
||||
if ([Environment]::Is64BitOperatingSystem) {
|
||||
$arch = "win64"
|
||||
}
|
||||
|
||||
mkdir -Force $global:NssmInstallDirectory
|
||||
DownloadFile nssm.zip https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/nssm-2.24.zip
|
||||
tar C $global:NssmInstallDirectory -xvf .\nssm.zip --strip-components 2 */$arch/*.exe
|
||||
Remove-Item -Force .\nssm.zip
|
||||
|
||||
$env:path += ";$global:NssmInstallDirectory"
|
||||
$newPath = "$global:NssmInstallDirectory;" +
|
||||
[Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine)
|
||||
|
||||
[Environment]::SetEnvironmentVariable("PATH", $newPath, [EnvironmentVariableTarget]::Machine)
|
||||
|
||||
Write-Host "Registering kubelet service"
|
||||
nssm install kubelet $global:Powershell $global:PowershellArgs $global:StartKubeletScript
|
||||
nssm set kubelet DependOnService docker
|
||||
|
||||
New-NetFirewallRule -Name kubelet -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250
|
||||
55
learn/learn-kubernetes-master/kiamol/ch18/packer/README.md
Normal file
55
learn/learn-kubernetes-master/kiamol/ch18/packer/README.md
Normal file
@@ -0,0 +1,55 @@
|
||||
Scripts for provisioning base Vagrant boxes.
|
||||
|
||||
## Hyper-V
|
||||
|
||||
Build:
|
||||
|
||||
```
|
||||
packer build -force -only=hyperv-iso -var "hyperv_switch=Default Switch" .\windows\windows-2019-core.json
|
||||
```
|
||||
|
||||
Export:
|
||||
|
||||
```
|
||||
vagrant box add --name kiamol-windows-2019 .\windows\windows-2019-core-hyperv.box
|
||||
```
|
||||
|
||||
Publish:
|
||||
|
||||
```
|
||||
vagrant cloud auth login
|
||||
|
||||
vagrant cloud provider create kiamol/windows-2019 hyperv 0.0.1
|
||||
vagrant cloud provider upload kiamol/windows-2019 hyperv 0.0.1 windows-2019-core-hyperv.box
|
||||
```
|
||||
|
||||
## VirtualBox
|
||||
|
||||
Build:
|
||||
|
||||
```
|
||||
packer build -force -only=virtualbox-iso .\windows\windows-2019-core.json
|
||||
```
|
||||
|
||||
Export:
|
||||
|
||||
```
|
||||
vagrant box add --name kiamol-windows-2019 .\windows\windows-2019-core-hyperv.box
|
||||
```
|
||||
|
||||
Publish:
|
||||
|
||||
```
|
||||
vagrant cloud auth login
|
||||
|
||||
vagrant cloud provider create kiamol/windows-2019 hyperv 0.0.1
|
||||
vagrant cloud provider upload kiamol/windows-2019 hyperv 0.0.1 windows-2019-core-hyperv.box
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
Bento: https://github.com/chef/bento
|
||||
|
||||
Stefan Scherer: https://github.com/StefanScherer/packer-windows
|
||||
|
||||
Boxcutter: https://github.com/boxcutter/windows-ps
|
||||
@@ -0,0 +1,289 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<unattend xmlns="urn:schemas-microsoft-com:unattend">
|
||||
<settings pass="windowsPE">
|
||||
<component name="Microsoft-Windows-PnpCustomizationsWinPE" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="amd64" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
|
||||
<!--
|
||||
This makes the VirtIO drivers available to Windows, assuming that
|
||||
the VirtIO driver disk at https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
|
||||
(see https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html#virtio-win-direct-downloads)
|
||||
is available as drive E:
|
||||
-->
|
||||
<DriverPaths>
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="2">
|
||||
<Path>E:\viostor\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="3">
|
||||
<Path>E:\NetKVM\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="4">
|
||||
<Path>E:\Balloon\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="5">
|
||||
<Path>E:\pvpanic\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="6">
|
||||
<Path>E:\qemupciserial\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="7">
|
||||
<Path>E:\qxldod\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="8">
|
||||
<Path>E:\vioinput\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="9">
|
||||
<Path>E:\viorng\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="10">
|
||||
<Path>E:\vioscsi\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
|
||||
<PathAndCredentials wcm:action="add" wcm:keyValue="11">
|
||||
<Path>E:\vioserial\2k19\amd64</Path>
|
||||
</PathAndCredentials>
|
||||
</DriverPaths>
|
||||
</component>
|
||||
<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>
|
||||
<UILanguage>en-US</UILanguage>
|
||||
</SetupUILanguage>
|
||||
<InputLocale>en-US</InputLocale>
|
||||
<SystemLocale>en-US</SystemLocale>
|
||||
<UILanguage>en-US</UILanguage>
|
||||
<UILanguageFallback>en-US</UILanguageFallback>
|
||||
<UserLocale>en-US</UserLocale>
|
||||
</component>
|
||||
<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>
|
||||
<Disk wcm:action="add">
|
||||
<CreatePartitions>
|
||||
<CreatePartition wcm:action="add">
|
||||
<Type>Primary</Type>
|
||||
<Order>1</Order>
|
||||
<Size>350</Size>
|
||||
</CreatePartition>
|
||||
<CreatePartition wcm:action="add">
|
||||
<Order>2</Order>
|
||||
<Type>Primary</Type>
|
||||
<Extend>true</Extend>
|
||||
</CreatePartition>
|
||||
</CreatePartitions>
|
||||
<ModifyPartitions>
|
||||
<ModifyPartition wcm:action="add">
|
||||
<Active>true</Active>
|
||||
<Format>NTFS</Format>
|
||||
<Label>boot</Label>
|
||||
<Order>1</Order>
|
||||
<PartitionID>1</PartitionID>
|
||||
</ModifyPartition>
|
||||
<ModifyPartition wcm:action="add">
|
||||
<Format>NTFS</Format>
|
||||
<Label>Windows 2019</Label>
|
||||
<Letter>C</Letter>
|
||||
<Order>2</Order>
|
||||
<PartitionID>2</PartitionID>
|
||||
</ModifyPartition>
|
||||
</ModifyPartitions>
|
||||
<DiskID>0</DiskID>
|
||||
<WillWipeDisk>true</WillWipeDisk>
|
||||
</Disk>
|
||||
</DiskConfiguration>
|
||||
<ImageInstall>
|
||||
<OSImage>
|
||||
<InstallFrom>
|
||||
<MetaData wcm:action="add">
|
||||
<Key>/IMAGE/NAME</Key>
|
||||
<Value>Windows Server 2019 SERVERDATACENTERCORE</Value>
|
||||
</MetaData>
|
||||
</InstallFrom>
|
||||
<InstallTo>
|
||||
<DiskID>0</DiskID>
|
||||
<PartitionID>2</PartitionID>
|
||||
</InstallTo>
|
||||
</OSImage>
|
||||
</ImageInstall>
|
||||
<UserData>
|
||||
<ProductKey>
|
||||
<WillShowUI>OnError</WillShowUI>
|
||||
</ProductKey>
|
||||
<AcceptEula>true</AcceptEula>
|
||||
<FullName>Vagrant</FullName>
|
||||
<Organization>Bento by Chef Software, Inc.</Organization>
|
||||
</UserData>
|
||||
</component>
|
||||
</settings>
|
||||
<settings pass="generalize">
|
||||
<component name="Microsoft-Windows-Security-SPP" 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">
|
||||
<SkipRearm>1</SkipRearm>
|
||||
</component>
|
||||
<component name="Microsoft-Windows-PnpSysprep" 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">
|
||||
<PersistAllDeviceInstalls>false</PersistAllDeviceInstalls>
|
||||
<DoNotCleanUpNonPresentDevices>false</DoNotCleanUpNonPresentDevices>
|
||||
</component>
|
||||
</settings>
|
||||
<settings pass="oobeSystem">
|
||||
<component name="Microsoft-Windows-International-Core" 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">
|
||||
<InputLocale>en-US</InputLocale>
|
||||
<SystemLocale>en-US</SystemLocale>
|
||||
<UILanguage>en-US</UILanguage>
|
||||
<UserLocale>en-US</UserLocale>
|
||||
</component>
|
||||
<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">
|
||||
<OOBE>
|
||||
<HideEULAPage>true</HideEULAPage>
|
||||
<HideLocalAccountScreen>true</HideLocalAccountScreen>
|
||||
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
|
||||
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
|
||||
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
|
||||
<NetworkLocation>Home</NetworkLocation>
|
||||
<ProtectYourPC>3</ProtectYourPC>
|
||||
<SkipMachineOOBE>true</SkipMachineOOBE>
|
||||
<SkipUserOOBE>true</SkipUserOOBE>
|
||||
</OOBE>
|
||||
<TimeZone>UTC</TimeZone>
|
||||
<UserAccounts>
|
||||
<AdministratorPassword>
|
||||
<Value>vagrant</Value>
|
||||
<PlainText>true</PlainText>
|
||||
</AdministratorPassword>
|
||||
<LocalAccounts>
|
||||
<LocalAccount wcm:action="add">
|
||||
<Password>
|
||||
<Value>vagrant</Value>
|
||||
<PlainText>true</PlainText>
|
||||
</Password>
|
||||
<Description>Vagrant User</Description>
|
||||
<DisplayName>vagrant</DisplayName>
|
||||
<Group>administrators</Group>
|
||||
<Name>vagrant</Name>
|
||||
</LocalAccount>
|
||||
</LocalAccounts>
|
||||
</UserAccounts>
|
||||
<AutoLogon>
|
||||
<Password>
|
||||
<Value>vagrant</Value>
|
||||
<PlainText>true</PlainText>
|
||||
</Password>
|
||||
<Username>vagrant</Username>
|
||||
<Enabled>true</Enabled>
|
||||
</AutoLogon>
|
||||
<FirstLogonCommands>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
|
||||
<Description>Set Execution Policy 64 Bit</Description>
|
||||
<Order>1</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
|
||||
<Description>Set Execution Policy 32 Bit</Description>
|
||||
<Order>2</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine>
|
||||
<Description>winrm quickconfig -q</Description>
|
||||
<Order>3</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</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">
|
||||
<CommandLine>cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE</CommandLine>
|
||||
<Order>16</Order>
|
||||
<Description>Disable password expiration for vagrant user</Description>
|
||||
</SynchronousCommand>
|
||||
</FirstLogonCommands>
|
||||
</component>
|
||||
</settings>
|
||||
<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-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
||||
<DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
|
||||
</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">
|
||||
<!-- Disable IE ESC. -->
|
||||
<IEHardenAdmin>false</IEHardenAdmin>
|
||||
<IEHardenUser>false</IEHardenUser>
|
||||
</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">
|
||||
<DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
|
||||
</component>
|
||||
</settings>
|
||||
</unattend>
|
||||
@@ -0,0 +1,11 @@
|
||||
# set PowerShell as default shell:
|
||||
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -name Shell -Value 'PowerShell.exe -noExit'
|
||||
|
||||
# add SSH:
|
||||
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
|
||||
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
|
||||
Start-Service sshd
|
||||
Set-Service -Name sshd -StartupType Automatic
|
||||
|
||||
# disable firewall :)
|
||||
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
|
||||
@@ -0,0 +1,3 @@
|
||||
Get-PackageProvider -name nuget -force
|
||||
Install-Module PSWindowsUpdate -confirm:$false -force
|
||||
Get-WindowsUpdate -Install -acceptall -IgnoreReboot
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "hyperv-iso",
|
||||
"communicator": "winrm",
|
||||
"cpus": "{{ user `cpus` }}",
|
||||
"floppy_files": [
|
||||
"{{ user `floppy_dir` }}/{{ user `unattended_file_path` }}"
|
||||
],
|
||||
"headless": "{{ user `headless` }}",
|
||||
"iso_checksum": "sha1:{{ user `iso_checksum` }}",
|
||||
"iso_url": "{{ user `iso_url` }}",
|
||||
"memory": "{{ user `memory` }}",
|
||||
"output_directory": "{{ user `build_directory` }}/packer-{{user `template`}}-virtualbox",
|
||||
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
|
||||
"shutdown_timeout": "15m",
|
||||
"switch_name": "{{user `hyperv_switch`}}",
|
||||
"winrm_password": "vagrant",
|
||||
"winrm_timeout": "12h",
|
||||
"winrm_username": "vagrant"
|
||||
},
|
||||
{
|
||||
"type": "virtualbox-iso",
|
||||
"communicator": "winrm",
|
||||
"cpus": "{{ user `cpus` }}",
|
||||
"floppy_files": [
|
||||
"{{ user `floppy_dir` }}/{{ user `unattended_file_path` }}"
|
||||
],
|
||||
"guest_additions_mode": "{{ user `guest_additions_mode` }}",
|
||||
"guest_additions_path": "C:/users/vagrant/VBoxGuestAdditions.iso",
|
||||
"guest_additions_url": "{{ user `guest_additions_url` }}",
|
||||
"guest_os_type": "Windows2016_64",
|
||||
"hard_drive_interface": "sata",
|
||||
"headless": "{{ user `headless` }}",
|
||||
"iso_checksum": "sha1:{{ user `iso_checksum` }}",
|
||||
"iso_interface": "sata",
|
||||
"iso_url": "{{ user `iso_url` }}",
|
||||
"memory": "{{ user `memory` }}",
|
||||
"output_directory": "{{ user `build_directory` }}/packer-{{user `template`}}-virtualbox",
|
||||
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
|
||||
"shutdown_timeout": "15m",
|
||||
"vboxmanage": [
|
||||
[
|
||||
"modifyvm",
|
||||
"{{.Name}}",
|
||||
"--vram",
|
||||
"48"
|
||||
],
|
||||
[
|
||||
"modifyvm",
|
||||
"{{.Name}}",
|
||||
"--audio",
|
||||
"none"
|
||||
]
|
||||
],
|
||||
"winrm_password": "vagrant",
|
||||
"winrm_timeout": "12h",
|
||||
"winrm_username": "vagrant"
|
||||
},
|
||||
{
|
||||
"type": "parallels-iso",
|
||||
"communicator": "winrm",
|
||||
"cpus": "{{ user `cpus` }}",
|
||||
"floppy_files": [
|
||||
"{{ user `floppy_dir` }}/{{ user `unattended_file_path` }}"
|
||||
],
|
||||
"guest_os_type": "win-2019",
|
||||
"iso_checksum": "sha1:{{ user `iso_checksum` }}",
|
||||
"iso_url": "{{ user `iso_url` }}",
|
||||
"memory": "{{ user `memory` }}",
|
||||
"output_directory": "{{ user `build_directory` }}/packer-{{user `template`}}-parallels",
|
||||
"parallels_tools_flavor": "win",
|
||||
"prlctl": [
|
||||
[
|
||||
"set",
|
||||
"{{.Name}}",
|
||||
"--efi-boot",
|
||||
"off"
|
||||
]
|
||||
],
|
||||
"prlctl_version_file": ".prlctl_version",
|
||||
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
|
||||
"shutdown_timeout": "15m",
|
||||
"winrm_password": "vagrant",
|
||||
"winrm_timeout": "12h",
|
||||
"winrm_username": "vagrant"
|
||||
}
|
||||
],
|
||||
"post-processors": [
|
||||
[
|
||||
{
|
||||
"keep_input_artifact": true,
|
||||
"output": "{{ user `template` }}-{{.Provider}}.box",
|
||||
"type": "vagrant"
|
||||
}
|
||||
]
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"elevated_password": "vagrant",
|
||||
"elevated_user": "vagrant",
|
||||
"script": "{{template_dir}}/scripts/win_updates.ps1",
|
||||
"type": "powershell"
|
||||
},
|
||||
{
|
||||
"type": "windows-restart"
|
||||
},
|
||||
{
|
||||
"elevated_password": "vagrant",
|
||||
"elevated_user": "vagrant",
|
||||
"script": "{{template_dir}}/scripts/ssh_setup.ps1",
|
||||
"type": "powershell"
|
||||
},
|
||||
{
|
||||
"type": "windows-restart"
|
||||
}
|
||||
],
|
||||
"variables": {
|
||||
"build_directory": "../../builds",
|
||||
"cpus": "2",
|
||||
"floppy_dir": "{{template_dir}}/answer_files",
|
||||
"guest_additions_mode": "attach",
|
||||
"guest_additions_url": "",
|
||||
"headless": "true",
|
||||
"hyperv_switch": "{{env `hyperv_switch`}}",
|
||||
"iso_checksum": "3022424f777b66a698047ba1c37812026b9714c5",
|
||||
"iso_url": "https://software-download.microsoft.com/download/pr/17763.737.190906-2324.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us_1.iso",
|
||||
"memory": "2048",
|
||||
"template": "windows-2019-core",
|
||||
"unattended_file_path": "2019/Autounattend.xml",
|
||||
"virtio_win_iso": "~/virtio-win.iso"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user