diff --git a/.gitignore b/.gitignore
index 03dc3d6..31e9abb 100755
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,6 @@ packer*
iso/*
iso*
extra/.snippets/*
-extra/.snippets*
\ No newline at end of file
+extra/.snippets*
+vbox/*
+*.box
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f55c6c8..a47520f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog
+## Version 1.0.7 2019-04-29
+
+* It's the last version before massive changes in packer >= 1.4 branch
+* [Windows] added more variables in Windows templates:
+ * `vm_name`
+ * `disk_size`
+ * `output_directory`
+ * `secondary_iso_image`
+* [Windows] switching secure boot to `false` as it could be source of problems in some cases
+* [Windows] added `Windows Server 2019 Standard` as `hv_win2019_std_g2`
+* [Windows] added `Windows Server 2019 Datacenter` as `hv_win2019_dc_g2`
+* [Windows] reworked `phase-1.ps1` script to recognise Windows version and adjust proper config for it
+* [Windows] reworked `phase-1.ps1` removed Spectre/Meltdown mitigations entries
+* [Docs]information `How to adjust autounattended.xml when using different image` now added to all Windows Templates.
+* [CentOS] added `reboot` after provisioning, which fixes neofetch config not being present during its customisation phase
+* [CentOS] added extra templates to make vagrant boxes from created images
+* [Extra] changes in scripts
+* [Vagrant] experimental support for Vagrant images (CentOS 7.6 added)
+
## Version 1.0.6 2018-12-11
* [Windows] added `Windows Server 1809` as `hv_win2016_1809_g2.json`
@@ -8,7 +27,7 @@
* [Windows] set `Disable-WindowsErrorReporting` for Windows based machines
* [CentOS] added CentOS 7.6 as `hv_centos76_g2.json`
* [CentOS] remove port 8140 from firewalld configuration
-* [CentOS] change zabbix repository to version 4.x (won't work with Zabbix server below 4.x)
+* [CentOS] change zabbix repository to version 4.x (agents won't work with Zabbix server below 4.x)
* [CentOS] added log cleaning/rotating after build
* [CentOS] upgraded SCVMM agent to version 1.0.3.1022. For older SCVMM older agent (1.0.2) is also available
* [Windows] added `phase5b-docker.ps1` for Windows's based docker. You can choose which version you'll require inside the script. Also, if `$installCompose = $true` is true, docker-compose will also be installed
diff --git a/README.md b/README.md
index a48c8f2..1ca4978 100644
--- a/README.md
+++ b/README.md
@@ -2,12 +2,28 @@
## Requirements
-* packer >= `1.3.2`. Do not use packer 1.3.0/1.3.1 - [https://github.com/hashicorp/packer/issues/6733](https://github.com/hashicorp/packer/issues/6733)
-* Microsoft Hyper-V Server 2016/Microsoft Windows Server 2016
+* packer >= `1.3.2` <=`1.3.5`. Do not use packer 1.3.0/1.3.1 - [https://github.com/hashicorp/packer/issues/6733](https://github.com/hashicorp/packer/issues/6733)
+* [OPTIONAL] Vagrant >= `2.2.3`
+* do not use packer >= `1.4.0` as it introduces changes in syntax (will be fixed in next release)
+* Microsoft Hyper-V Server 2016/2019 or Microsoft Windows Server 2016/2019
## Usage
-To adjust to your Hyper-V, please check variables below:
+### Install packer from Chocolatey
+
+```cmd
+choco install packer --version=1.3.5
+```
+
+### Add firewal exclusions for TCP ports 8000-9000 (default range)
+
+```powershell
+Remove-NetFirewallRule -DisplayName "Packer_http_server" -Verbose
+New-NetFirewallRule -DisplayName "Packer_http_server" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 8000-9000
+
+```
+
+### To adjust to your Hyper-V, please check variables below:
* proper VLAN (possible passing as variable `-var 'vlan_id=0'` )
* proper Hyper-V Virtual Switch name (access to Internet will be required) (possible passing as variable `-var 'switch_name=vSwitch'` )
@@ -22,22 +38,32 @@ To adjust to your Hyper-V, please check variables below:
### Windows Machines
* all available updates will be applied (3 passes)
-* latest chocolatey and packages will be installed:
+* latest version of chocolatey
+* packages from a list below:
|Package|Version|
|-------|-------|
- |puppet-agent|5.5.8|
+ |puppet-agent|5.5.12|
|conemu|latest|
|dotnet4.7.2|latest|
|sysinternals|latest|
-
-* puppet agent settings will be customized (`server=foreman.spcph.local`). Please adjust it to suit your needs.
+* latest Nuget poweshell module
+* puppet agent settings will be customized (`server=foreman.spcph.local`). Please adjust it (`/extra/scripts/phase-3.ps1`) to suit your needs. Puppet won't be running after generalize phase
### Linux Machines
+* Repositories:
+ * EPEL 7
+ * Zabbix 4.x
+ * Puppet 5.x
+ * Webmin
+ * Neofetch
+* latest System Center Virtual Machine Agent available (with versioning, so you always can go back)
+
+#### Info
+
* adjust `/files/provision.sh` to modify package's versions/servers
* `neofetch` packageas default banner during after the login - change required fields you'd like to see in `provision.sh`
-* latest System Center Virtual Machine Agent available (with versioning, so you always can go back)
## Templates Windows 2016
@@ -45,25 +71,73 @@ To adjust to your Hyper-V, please check variables below:
Run `hv_win2016_g2.cmd` (Windows)
-#### Generation 2 Prerequisites
+#### 2016 Standard Generation 2 Prerequisites
For Generation 2 prepare `secondary.iso` with folder structure:
* ./extra/files/gen2-2016/Autounattend.xml => /Autounattend.xml
* ./extra/scripts/hyper-v/bootstrap.ps1 => /bootstrap.ps1
+This template uses this image name in Autounattendes.xml. If youre using different ISO you'll have to adjust that part in proper file and rebuild `secondary.iso` image.
+
+```xml
+
+
+ /IMAGE/NAME
+ Windows Server 2016 SERVERSTANDARD
+
+
+```
+
Run `hv_win2016_g2.cmd` (Windows)
-### Hyper-V Generation 2 Windows Server 1709 Standard Image
+### Hyper-V Generation 2 Windows Server 2019 Standard Image
-#### 1709 Generation 2 Prerequisites
+Run `hv_win2019_std_g2.cmd` (Windows)
-For Generation 2 prepare `secondary1709.iso` with folder structure:
+#### 2019 Standard Generation 2 Prerequisites
-* ./extra/files/gen2-1709/Autounattend.xml => /Autounattend.xml
-* ./extra/scripts/hyper-v/bootstrap.ps1 => /bootstrap.ps1
+For Generation 2 prepare `secondary.iso` with folder structure:
+
+* ./extra/files/gen2-2019/std/Autounattend.xml => /Autounattend.xml
+* ./extra/scripts/hyper-v/bootstrap.ps1 => /bootstrap.ps1
+
+This template uses this image name in Autounattendes.xml. If youre using different ISO you'll have to adjust that part in proper file and rebuild `secondary.iso` image.
+
+```xml
+
+
+ /IMAGE/NAME
+ Windows Server 2019 SERVERSTANDARD
+
+
+```
+
+Run `hv_win2019_std_g2.cmd` (Windows)
+
+### Hyper-V Generation 2 Windows Server 2019 Datacenter Image
-Run `hv_win2016_1709_g2.cmd` (Windows)
+Run `hv_win2019_std_g2.cmd` (Windows)
+
+#### 2019 Datacenter Generation 2 Prerequisites
+
+For Generation 2 prepare `secondary.iso` with folder structure:
+
+* ./extra/files/gen2-2019/dc/Autounattend.xml => /Autounattend.xml
+* ./extra/scripts/hyper-v/bootstrap.ps1 => /bootstrap.ps1
+
+This template uses this image name in Autounattendes.xml. If youre using different ISO you'll have to adjust that part in proper file and rebuild `secondary.iso` image.
+
+```xml
+
+
+ /IMAGE/NAME
+ Windows Server 2019 SERVERDATACENTER
+
+
+```
+
+Run `hv_win2019_dc_g2.cmd` (Windows)
### Hyper-V Generation 2 Windows Server 1803 Standard Image
@@ -76,23 +150,38 @@ For Generation 2 prepare `secondary1803.iso` with folder structure:
Run `hv_win2016_1803_g2.cmd` (Windows)
+### Hyper-V Generation 2 Windows Server 1809 Standard Image
+
+#### 1809 Generation 2 Prerequisites
+
+For Generation 2 prepare `secondary1809.iso` with folder structure:
+
+* ./extra/files/gen2-1809/Autounattend.xml => /Autounattend.xml
+* ./extra/scripts/hyper-v/bootstrap.ps1 => /bootstrap.ps1
+
+Run `hv_win2016_1809_g2.cmd` (Windows)
+
## Templates CentOS 7.x
-### Hyper-V Generation 2 CentOS 7.5 Image
+### Hyper-V Generation 2 CentOS 7.6 Image
-Run `hv_centos75_g2.cmd` (Windows)
+Run `hv_centos76_g2.cmd` (Windows)
### Warnings
* if required change `switch_name` parameter to switch's name you're using. In most situations packer manages it fine but there were a cases when it created new 'internal' switches without access to Internet. By design this setup will fail to download and apply updates.
* folder `./iso` should contain iso image of your Windows 2016 Server Standard (any version will be fine)
* if needed - change `iso_url` variable to a proper iso name
-* packer generates v8 machine configuration files (Windows 2016/Hyper-V 2016 as host)
+* packer generates v8 machine configuration files (Windows 2016/Hyper-V 2016 as host) and v9 for Windows Server 2019/Windows 10 1809
* credentials for Windows machines: Administrator/password (removed after sysprep)
* credentials for Linux machines: root/password
* for Windows based machines adjust your settings in ./scripts/phase-2.ps1
* for Linux based machines adjust your settings in ./files/gen2-centos/provision.sh and ./files/gen2-centos/puppet.conf
+### Vagrant support
+
+Experimental support for vagrant machines `vagrant_hv_centos76_g2.cmd`
+
## Known issues
### Infamous UEFI/Secure boot WIndows implementation
@@ -100,6 +189,12 @@ Run `hv_centos75_g2.cmd` (Windows)
During the deployment secure keys are stored in *.vmcx file and are separated from *.vhdx file. To countermeasure it - there is added extra step in a form of (`/usr/local/bin/uefi.sh`) script that will check for existence of CentOS folder in EFI and will add extra entry in UEFI.
In manual setup you can run it as a part of your deploy. In SCVMM deployment I'd recommend using `RunOnce` feature.
+### On Windows Server 2019/Windows 10 1809 image boots to fast for packer to react.
+
+[https://github.com/hashicorp/packer/issues/7278#issuecomment-468492880](https://github.com/hashicorp/packer/issues/7278#issuecomment-468492880)
+
+No fixes yes.
+
### When Hyper-V host has more than one interface Packer sets {{ .HTTPIP }} variable to inproper interface
No resolution so far, template needs to be changed to pass real IP address, or there should be connection between these addresses. Limiting these, end with timeout errors.
@@ -108,6 +203,32 @@ No resolution so far, template needs to be changed to pass real IP address, or t
[https://github.com/hashicorp/packer/issues/6733](https://github.com/hashicorp/packer/issues/6733)
+### Packer won't run until VirtualSwitch is created as shared
+
+[https://github.com/hashicorp/packer/issues/5023](https://github.com/hashicorp/packer/issues/5023)
+Will be fixed in 1.4.x revision
+
+### I have problem how to find a proper WIM name in Windows ISO to pick proper version.
+
+You can use number. If you have 4 images on the list of choice - use `ImageIndex` with proper `Value`
+
+```xml
+
+
+
+
+ /IMAGE/INDEX
+ 2
+
+
+
+ 0
+ 2
+
+
+
+```
+
## About
* Marcin Bojko - marcin(at)bojko.com.pl
diff --git a/extra/.snippets/sshd_config.sh b/extra/.snippets/sshd_config.sh
deleted file mode 100644
index 5e18559..0000000
--- a/extra/.snippets/sshd_config.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-augtool --autosave 'rm /files/etc/ssh/sshd_config/UseDns yes'
-augtool --autosave 'set /files/etc/ssh/sshd_config/UseDns no'
-print /files/etc/ssh/sshd_config/#comment[. = "UseLogin no"]
diff --git a/extra/README.md b/extra/README.md
index cf150fe..71c1308 100644
--- a/extra/README.md
+++ b/extra/README.md
@@ -1,5 +1,14 @@
# Set of various shared scripts and files for packer templates
+## 2019-03-04
+
+* disabled `Install-WindowsFeature NET-Framework-Core,NET-Framework-Features,PowerShell-V2 -IncludeManagementTools` in phase-1.ps1 script.
+
+## 2018-12-29
+
+* [Windows] reworked `phase-1.ps1` script to recognise Windows version to adjust proper config for it
+* [Windows] reworked `phase-1.ps1` removed Spectre/Meltdown migitation entries
+
## 2018-12-03
* [CentOS] remove port 8140 from firewalld configuration
diff --git a/extra/files/gen1-vb/10-1809/unattend.xml b/extra/files/gen1-vb/10-1809/unattend.xml
new file mode 100644
index 0000000..c5b497a
--- /dev/null
+++ b/extra/files/gen1-vb/10-1809/unattend.xml
@@ -0,0 +1,60 @@
+
+
+
+
+ 1
+
+
+ false
+ false
+
+
+
+
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+ true
+ 1
+ true
+ true
+ true
+ true
+
+ UTC
+
+
+ vagrant
+ true
+
+
+
+
+ vagrant
+ true
+
+ administrators
+ Vagrant
+ vagrant
+ Vagrant User
+
+
+
+
+
+
+
+
+ true
+
+
+
+ vagrant-10
+
+
+
+
diff --git a/extra/files/gen1-vb/1803-dc/Autounattend.xml b/extra/files/gen1-vb/1803-dc/Autounattend.xml
new file mode 100644
index 0000000..646797e
--- /dev/null
+++ b/extra/files/gen1-vb/1803-dc/Autounattend.xml
@@ -0,0 +1,154 @@
+
+
+
+
+
+ en-US
+
+ en-US
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+
+
+
+ Primary
+ 1
+ 350
+
+
+ 2
+ Primary
+ true
+
+
+
+
+ true
+ NTFS
+
+ 1
+ 1
+
+
+ NTFS
+
+ C
+ 2
+ 2
+
+
+ 0
+ true
+
+
+
+
+
+
+ /IMAGE/INDEX
+ 2
+
+
+
+ 0
+ 2
+
+
+
+
+
+
+ OnError
+
+ true
+ Vagrant
+ Hashicorp
+
+
+
+
+
+
+ false
+
+ vagrant-1803
+ Pacific Standard Time
+
+
+
+ true
+
+
+ false
+ false
+
+
+ true
+
+
+
+
+
+
+ vagrant
+ true
+
+ true
+ vagrant
+
+
+
+ cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 64 Bit
+ 1
+ true
+
+
+ C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 32 Bit
+ 2
+ true
+
+
+ cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\bootstrap.ps1
+ Fix public network
+ 3
+ true
+
+
+ cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
+ 4
+ Disable password expiration for vagrant user
+
+
+
+
+ vagrant
+ true
+
+
+
+
+ vagrant
+ true
+
+ Vagrant User
+ Administrators
+ vagrant
+
+
+
+
+
+
+
+ false
+
+
+
+
diff --git a/extra/files/gen1-vb/1803-dc/unattend.xml b/extra/files/gen1-vb/1803-dc/unattend.xml
new file mode 100755
index 0000000..d1f3bd3
--- /dev/null
+++ b/extra/files/gen1-vb/1803-dc/unattend.xml
@@ -0,0 +1,53 @@
+
+
+
+
+ 1
+
+
+ false
+ false
+
+
+
+
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+ true
+ 1
+ true
+
+ UTC
+
+
+ dgBhAGcAcgBhAG4AdABBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=
+ false
+
+
+
+
+ dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA
+ false
+
+ administrators
+ Vagrant
+ vagrant
+ Vagrant User
+
+
+
+
+
+
+
+
+ vagrant-1709
+
+
+
+
diff --git a/extra/files/gen1-vb/1803/Autounattend.xml b/extra/files/gen1-vb/1803/Autounattend.xml
new file mode 100644
index 0000000..3e88e3a
--- /dev/null
+++ b/extra/files/gen1-vb/1803/Autounattend.xml
@@ -0,0 +1,154 @@
+
+
+
+
+
+ en-US
+
+ en-US
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+
+
+
+ Primary
+ 1
+ 350
+
+
+ 2
+ Primary
+ true
+
+
+
+
+ true
+ NTFS
+
+ 1
+ 1
+
+
+ NTFS
+
+ C
+ 2
+ 2
+
+
+ 0
+ true
+
+
+
+
+
+
+ /IMAGE/INDEX
+ 1
+
+
+
+ 0
+ 2
+
+
+
+
+
+
+ OnError
+
+ true
+ Vagrant
+ Hashicorp
+
+
+
+
+
+
+ false
+
+ vagrant-1803
+ Pacific Standard Time
+
+
+
+ true
+
+
+ false
+ false
+
+
+ true
+
+
+
+
+
+
+ vagrant
+ true
+
+ true
+ vagrant
+
+
+
+ cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 64 Bit
+ 1
+ true
+
+
+ C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 32 Bit
+ 2
+ true
+
+
+ cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\bootstrap.ps1
+ Fix public network
+ 3
+ true
+
+
+ cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
+ 4
+ Disable password expiration for vagrant user
+
+
+
+
+ vagrant
+ true
+
+
+
+
+ vagrant
+ true
+
+ Vagrant User
+ Administrators
+ vagrant
+
+
+
+
+
+
+
+ false
+
+
+
+
diff --git a/extra/files/gen1-vb/1803/unattend.xml b/extra/files/gen1-vb/1803/unattend.xml
new file mode 100755
index 0000000..d1f3bd3
--- /dev/null
+++ b/extra/files/gen1-vb/1803/unattend.xml
@@ -0,0 +1,53 @@
+
+
+
+
+ 1
+
+
+ false
+ false
+
+
+
+
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+ true
+ 1
+ true
+
+ UTC
+
+
+ dgBhAGcAcgBhAG4AdABBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=
+ false
+
+
+
+
+ dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA
+ false
+
+ administrators
+ Vagrant
+ vagrant
+ Vagrant User
+
+
+
+
+
+
+
+
+ vagrant-1709
+
+
+
+
diff --git a/extra/files/gen1-vb/1809-dc/Autounattend.xml b/extra/files/gen1-vb/1809-dc/Autounattend.xml
new file mode 100644
index 0000000..20ad910
--- /dev/null
+++ b/extra/files/gen1-vb/1809-dc/Autounattend.xml
@@ -0,0 +1,154 @@
+
+
+
+
+
+ en-US
+
+ en-US
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+
+
+
+ Primary
+ 1
+ 350
+
+
+ 2
+ Primary
+ true
+
+
+
+
+ true
+ NTFS
+
+ 1
+ 1
+
+
+ NTFS
+
+ C
+ 2
+ 2
+
+
+ 0
+ true
+
+
+
+
+
+
+ /IMAGE/INDEX
+ 2
+
+
+
+ 0
+ 2
+
+
+
+
+
+
+ OnError
+
+ true
+ Vagrant
+ Hashicorp
+
+
+
+
+
+
+ false
+
+ vagrant-1809
+ Pacific Standard Time
+
+
+
+ true
+
+
+ false
+ false
+
+
+ true
+
+
+
+
+
+
+ vagrant
+ true
+
+ true
+ vagrant
+
+
+
+ cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 64 Bit
+ 1
+ true
+
+
+ C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 32 Bit
+ 2
+ true
+
+
+ cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\bootstrap.ps1
+ Fix public network
+ 3
+ true
+
+
+ cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
+ 4
+ Disable password expiration for vagrant user
+
+
+
+
+ vagrant
+ true
+
+
+
+
+ vagrant
+ true
+
+ Vagrant User
+ Administrators
+ vagrant
+
+
+
+
+
+
+
+ false
+
+
+
+
diff --git a/extra/files/gen1-vb/1809-dc/unattend.xml b/extra/files/gen1-vb/1809-dc/unattend.xml
new file mode 100755
index 0000000..d1f3bd3
--- /dev/null
+++ b/extra/files/gen1-vb/1809-dc/unattend.xml
@@ -0,0 +1,53 @@
+
+
+
+
+ 1
+
+
+ false
+ false
+
+
+
+
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+ true
+ 1
+ true
+
+ UTC
+
+
+ dgBhAGcAcgBhAG4AdABBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=
+ false
+
+
+
+
+ dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA
+ false
+
+ administrators
+ Vagrant
+ vagrant
+ Vagrant User
+
+
+
+
+
+
+
+
+ vagrant-1709
+
+
+
+
diff --git a/extra/files/gen1-vb/1809/Autounattend.xml b/extra/files/gen1-vb/1809/Autounattend.xml
new file mode 100644
index 0000000..38c58c3
--- /dev/null
+++ b/extra/files/gen1-vb/1809/Autounattend.xml
@@ -0,0 +1,154 @@
+
+
+
+
+
+ en-US
+
+ en-US
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+
+
+
+ Primary
+ 1
+ 350
+
+
+ 2
+ Primary
+ true
+
+
+
+
+ true
+ NTFS
+
+ 1
+ 1
+
+
+ NTFS
+
+ C
+ 2
+ 2
+
+
+ 0
+ true
+
+
+
+
+
+
+ /IMAGE/INDEX
+ 1
+
+
+
+ 0
+ 2
+
+
+
+
+
+
+ OnError
+
+ true
+ Vagrant
+ Hashicorp
+
+
+
+
+
+
+ false
+
+ vagrant-1809
+ Pacific Standard Time
+
+
+
+ true
+
+
+ false
+ false
+
+
+ true
+
+
+
+
+
+
+ vagrant
+ true
+
+ true
+ vagrant
+
+
+
+ cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 64 Bit
+ 1
+ true
+
+
+ C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 32 Bit
+ 2
+ true
+
+
+ cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\bootstrap.ps1
+ Fix public network
+ 3
+ true
+
+
+ cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
+ 4
+ Disable password expiration for vagrant user
+
+
+
+
+ vagrant
+ true
+
+
+
+
+ vagrant
+ true
+
+ Vagrant User
+ Administrators
+ vagrant
+
+
+
+
+
+
+
+ false
+
+
+
+
diff --git a/extra/files/gen1-vb/1809/unattend.xml b/extra/files/gen1-vb/1809/unattend.xml
new file mode 100755
index 0000000..d1f3bd3
--- /dev/null
+++ b/extra/files/gen1-vb/1809/unattend.xml
@@ -0,0 +1,53 @@
+
+
+
+
+ 1
+
+
+ false
+ false
+
+
+
+
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+ true
+ 1
+ true
+
+ UTC
+
+
+ dgBhAGcAcgBhAG4AdABBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=
+ false
+
+
+
+
+ dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA
+ false
+
+ administrators
+ Vagrant
+ vagrant
+ Vagrant User
+
+
+
+
+
+
+
+
+ vagrant-1709
+
+
+
+
diff --git a/extra/files/gen1-vb/2019/Autounattend.xml b/extra/files/gen1-vb/2019/Autounattend.xml
new file mode 100644
index 0000000..580b178
--- /dev/null
+++ b/extra/files/gen1-vb/2019/Autounattend.xml
@@ -0,0 +1,153 @@
+
+
+
+
+
+ en-US
+
+ en-US
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+
+
+
+ Primary
+ 1
+ 350
+
+
+ 2
+ Primary
+ true
+
+
+
+
+ true
+ NTFS
+
+ 1
+ 1
+
+
+ NTFS
+
+ C
+ 2
+ 2
+
+
+ 0
+ true
+
+
+
+
+
+
+ /IMAGE/NAME
+ Windows Server 2019 SERVERSTANDARD
+
+
+
+ 0
+ 2
+
+
+
+
+
+
+ OnError
+
+ true
+ Vagrant
+ Hashicorp
+
+
+
+
+
+
+ false
+
+ vagrant-2019
+ Pacific Standard Time
+
+
+
+ true
+
+
+ false
+ false
+
+
+ true
+
+
+
+
+
+
+ vagrant
+ true
+
+ true
+ vagrant
+
+
+
+ cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 64 Bit
+ 1
+ true
+
+
+ C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 32 Bit
+ 2
+ true
+
+
+ cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\bootstrap.ps1
+ Fix public network
+ 3
+ true
+
+
+ cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
+ 4
+ Disable password expiration for vagrant user
+
+
+
+
+ vagrant
+ true
+
+
+
+
+ vagrant
+ true
+
+ Vagrant User
+ Administrators
+ vagrant
+
+
+
+
+
+
+
+ false
+
+
+
diff --git a/extra/files/gen1-vb/2019/unattend.xml b/extra/files/gen1-vb/2019/unattend.xml
new file mode 100755
index 0000000..b8496ce
--- /dev/null
+++ b/extra/files/gen1-vb/2019/unattend.xml
@@ -0,0 +1,52 @@
+
+
+
+
+ 1
+
+
+ false
+ false
+
+
+
+
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+ true
+ 1
+ true
+
+ UTC
+
+
+ dgBhAGcAcgBhAG4AdABBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=
+ false
+
+
+
+
+ dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA
+ false
+
+ administrators
+ Vagrant
+ vagrant
+ Vagrant User
+
+
+
+
+
+
+
+
+ vagrant-2019
+
+
+
diff --git a/extra/files/gen2-2019/dc/Autounattend.xml b/extra/files/gen2-2019/dc/Autounattend.xml
new file mode 100755
index 0000000..c76dc3c
--- /dev/null
+++ b/extra/files/gen2-2019/dc/Autounattend.xml
@@ -0,0 +1,171 @@
+
+
+
+
+
+ en-US
+
+ en-US
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+
+
+
+ 1
+ 350
+ Primary
+
+
+ 2
+ 100
+ EFI
+
+
+ 3
+ 128
+ MSR
+
+
+ 4
+ true
+ Primary
+
+
+
+
+ 1
+ 1
+
+ NTFS
+ de94bba4-06d1-4d40-a16a-bfd50179d6ac
+
+
+ 2
+ 2
+
+ FAT32
+
+
+ 3
+ 3
+
+
+ 4
+ 4
+
+ NTFS
+
+
+ 0
+ true
+
+ OnError
+
+
+
+
+
+ /IMAGE/NAME
+ Windows Server 2019 SERVERDATACENTER
+
+
+
+ 0
+ 4
+
+
+
+
+
+
+ OnError
+
+ true
+ Administrator
+
+
+
+
+
+
+
+ false
+
+ windows-2019
+ Central European Standard Time
+
+
+
+ true
+
+
+ false
+ false
+
+
+ true
+
+
+
+
+
+
+ password
+ true
+
+ true
+ Administrator
+
+
+
+ cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 64 Bit
+ 1
+ true
+
+
+ C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 32 Bit
+ 2
+ true
+
+
+ cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File e:\bootstrap.ps1
+ bootstrap
+ 3
+ true
+
+
+ cmd.exe /c wmic useraccount where "name='Administrator'" set PasswordExpires=FALSE
+ 4
+ Disable password expiration for Administrator user
+
+
+
+ true
+ true
+ true
+ true
+ true
+ Home
+ 1
+
+
+
+ password
+ true
+
+
+
+
+
+
+ false
+
+
+
diff --git a/extra/files/gen2-2019/dc/secondary.iso b/extra/files/gen2-2019/dc/secondary.iso
new file mode 100644
index 0000000..2d04979
Binary files /dev/null and b/extra/files/gen2-2019/dc/secondary.iso differ
diff --git a/extra/files/gen2-2019/std/Autounattend.xml b/extra/files/gen2-2019/std/Autounattend.xml
new file mode 100755
index 0000000..2727744
--- /dev/null
+++ b/extra/files/gen2-2019/std/Autounattend.xml
@@ -0,0 +1,171 @@
+
+
+
+
+
+ en-US
+
+ en-US
+ en-US
+ en-US
+ en-US
+ en-US
+
+
+
+
+
+
+ 1
+ 350
+ Primary
+
+
+ 2
+ 100
+ EFI
+
+
+ 3
+ 128
+ MSR
+
+
+ 4
+ true
+ Primary
+
+
+
+
+ 1
+ 1
+
+ NTFS
+ de94bba4-06d1-4d40-a16a-bfd50179d6ac
+
+
+ 2
+ 2
+
+ FAT32
+
+
+ 3
+ 3
+
+
+ 4
+ 4
+
+ NTFS
+
+
+ 0
+ true
+
+ OnError
+
+
+
+
+
+ /IMAGE/NAME
+ Windows Server 2019 SERVERSTANDARD
+
+
+
+ 0
+ 4
+
+
+
+
+
+
+ OnError
+
+ true
+ Administrator
+
+
+
+
+
+
+
+ false
+
+ windows-2019
+ Central European Standard Time
+
+
+
+ true
+
+
+ false
+ false
+
+
+ true
+
+
+
+
+
+
+ password
+ true
+
+ true
+ Administrator
+
+
+
+ cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 64 Bit
+ 1
+ true
+
+
+ C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
+ Set Execution Policy 32 Bit
+ 2
+ true
+
+
+ cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File e:\bootstrap.ps1
+ bootstrap
+ 3
+ true
+
+
+ cmd.exe /c wmic useraccount where "name='Administrator'" set PasswordExpires=FALSE
+ 4
+ Disable password expiration for Administrator user
+
+
+
+ true
+ true
+ true
+ true
+ true
+ Home
+ 1
+
+
+
+ password
+ true
+
+
+
+
+
+
+ false
+
+
+
diff --git a/extra/files/gen2-2019/std/secondary.iso b/extra/files/gen2-2019/std/secondary.iso
new file mode 100644
index 0000000..bee88a5
Binary files /dev/null and b/extra/files/gen2-2019/std/secondary.iso differ
diff --git a/extra/files/gen2-centos/scagent/1.0.2.1075/install b/extra/files/gen2-centos/scagent/1.0.2.1075/install
old mode 100755
new mode 100644
diff --git a/extra/files/gen2-centos/scagent/1.0.2.1075/scvmmguestagent.1.0.2.1075.x64.tar b/extra/files/gen2-centos/scagent/1.0.2.1075/scvmmguestagent.1.0.2.1075.x64.tar
old mode 100755
new mode 100644
diff --git a/extra/scripts/azure/bootstrap.cmd b/extra/scripts/azure/bootstrap.cmd
new file mode 100644
index 0000000..56b1381
--- /dev/null
+++ b/extra/scripts/azure/bootstrap.cmd
@@ -0,0 +1,4 @@
+net user /add adpacker xBph2L?h
+net localgroup administrators adpacker /add
+PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList 'Set-ExecutionPolicy Bypass -Force' -Verb RunAs}"
+
diff --git a/extra/scripts/azure/bootstrap.ps1 b/extra/scripts/azure/bootstrap.ps1
index 519d9aa..f9d5338 100644
--- a/extra/scripts/azure/bootstrap.ps1
+++ b/extra/scripts/azure/bootstrap.ps1
@@ -1,8 +1,16 @@
# Create new azure admin user
Write-Output "Bootstrap: Start"
+Get-ExecutionPolicy -Verbose
+Import-Module ServerManager
$username="adpacker"
$secure_pwd = ConvertTo-SecureString 'xBph2L?h' -AsPlainText -Force
-Remove-LocalUser -Name $username -ErrorAction SilentlyContinue
-New-LocalUser $username -Password $secure_pwd -FullName $username -Description "packer azure deploy user"
-Add-LocalGroupMember -Group "Administrators" -Member $username
+Remove-LocalUser -Name $username -ErrorAction SilentlyContinue -Verbose
+try {
+ New-LocalUser $username -Password $secure_pwd -FullName $username -Description "packer azure deploy user" -Verbose
+ Add-LocalGroupMember -Group "Administrators" -Member $username -Verbose
+}
+catch {
+ Write-Output "Adding user $username failed"
+}
+
Write-Output "Bootstrap: End"
\ No newline at end of file
diff --git a/extra/scripts/azure/post-phase-4.ps1 b/extra/scripts/azure/post-phase-4.ps1
index 9149af4..df3ccec 100644
--- a/extra/scripts/azure/post-phase-4.ps1
+++ b/extra/scripts/azure/post-phase-4.ps1
@@ -1,6 +1,19 @@
# remove deploy user
Write-Output "Post-Phase-4: Start"
$username="adpacker"
-Get-WMIObject -Class Win32_UserProfile | Where-Object {($_.LocalPath -like "*$username*")} | Remove-WMIObject
-Remove-LocalUser -Name $username -ErrorAction SilentlyContinue
+try {
+ Get-WMIObject -Class Win32_UserProfile | Where-Object {($_.LocalPath -like "*$username*")} | Remove-WMIObject -Verbose
+ Write-Output "Profile of $username removed"
+}
+catch {
+ Write-Output "Failure in removing WMI profile for: $username"
+}
+
+try {
+ Remove-LocalUser -Name $username -ErrorAction SilentlyContinue -Verbose
+ Write-Output "Account of $username removed"
+}
+catch {
+ Write-Output "Failure in removing local user: $username"
+}
Write-Output "Post-Phase-4: End"
diff --git a/extra/scripts/phase-1.ps1 b/extra/scripts/phase-1.ps1
index f2d89a6..7a32972 100755
--- a/extra/scripts/phase-1.ps1
+++ b/extra/scripts/phase-1.ps1
@@ -1,40 +1,107 @@
+# Main Phase-1 script
+# Windows Features, Firewall rules and registry entries,chocolatey
+
+# Variables
+$global:os=""
+function whichWindows {
+$version=(Get-WMIObject win32_operatingsystem).name
+ switch -Regex ($version) {
+ '(Server 2016)' {
+ Write-Output "Server 2016 found"
+ $global:os="2016"
+ }
+ '(Server 2019)' {
+ Write-Output "Server 2019 found"
+ $global:os="2019"
+ }
+ '(Microsoft Windows Server Standard|Microsoft Windows Server Datacenter)'{
+ $ws_version=(Get-WmiObject win32_operatingsystem).buildnumber
+ switch -Regex ($ws_version) {
+ '16299' {
+ Write-Output "Windows Server 1709 found"
+ $global:os="1709"
+ }
+ '17134' {
+ Write-Output "Windows Server 1803 found"
+ $global:os="1803"
+ }
+ '17763' {
+ Write-Output "Windows Server 1809 found"
+ $global:os="1809"
+ }
+ }
+ }
+ '(Windows 10)' {
+ Write-Output 'Windows 10 found'
+ $global:os="10"
+ }
+ default
+ {Write-Output "unknown"}
+ }
+}
+whichWindows
# Phase 1 - Mandatory generic stuff
Write-Output "Start of Phase-1"
Import-Module ServerManager
-Install-WindowsFeature NET-Framework-Core,NET-Framework-Features,PowerShell-V2 -IncludeManagementTools
-Install-WindowsFeature NET-Framework-45-Core,Telnet-Client,RSAT-Role-Tools -IncludeManagementTools
-Install-WindowsFeature SNMP-Service,SNMP-WMI-Provider -IncludeManagementTools
-Enable-NetFirewallRule -DisplayGroup "Remote Desktop" -Verbose
-Enable-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Verbose
-Enable-NetFirewallRule -DisplayGroup "Remote Service Management" -Verbose
-Enable-NetFirewallRule -DisplayGroup "Performance Logs and Alerts" -Verbose
-Enable-NetFirewallRule -DisplayGroup "Windows Firewall Remote Management" -Verbose
-Enable-NetFirewallRule -DisplayGroup "Windows Management Instrumentation (WMI)" -Verbose
-Enable-NetFirewallRule -DisplayGroup "Remote Service Management" -Verbose
-Enable-NetFirewallRule -DisplayName "File and Printer Sharing (Echo Request - ICMPv4-In)" -Verbose
-Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0 -Verbose -Force
-Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 0 -Verbose -Force
-Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -Value 0 -Verbose -Force
-Set-ItemProperty -Path 'HKLM:\SYSTEM\Setup\Status\SysprepStatus' -Name 'GeneralizationState' -Value 7 -Verbose -Force
-Remove-WindowsFeature -Name Windows-Defender-Features -IncludeManagementTools -ErrorAction SilentlyContinue -Verbose
-Set-ExecutionPolicy Bypass; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
-# Disable ansible script
-# Set-ExecutionPolicy Bypass; Invoke-Expression ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))
+#2016/1709/1803/1809
+if ($global:os -notlike '2019') {
+ # Install-WindowsFeature NET-Framework-Core,NET-Framework-Features,PowerShell-V2 -IncludeManagementTools
+}
+# 1709/1803/1809/2019
+if ($global:os -notlike '2016') {
+ Enable-NetFirewallRule -DisplayGroup "Windows Defender Firewall Remote Management" -Verbose
+}
+# 2016
+if ($global:os -eq '2016') {
+ Enable-NetFirewallRule -DisplayGroup "Windows Firewall Remote Management" -Verbose
+}
+
+
+
+# features and firewall rules common for all Windows Servers
+try {
+ Install-WindowsFeature NET-Framework-45-Core,Telnet-Client,RSAT-Role-Tools -IncludeManagementTools
+ Install-WindowsFeature SNMP-Service,SNMP-WMI-Provider -IncludeManagementTools
+ Enable-NetFirewallRule -DisplayGroup "Remote Desktop" -Verbose
+ Enable-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Verbose
+ Enable-NetFirewallRule -DisplayGroup "Remote Service Management" -Verbose
+ Enable-NetFirewallRule -DisplayGroup "Performance Logs and Alerts" -Verbose
+ Enable-NetFirewallRule -DisplayGroup "Windows Management Instrumentation (WMI)" -Verbose
+ Enable-NetFirewallRule -DisplayGroup "Remote Service Management" -Verbose
+ Enable-NetFirewallRule -DisplayName "File and Printer Sharing (Echo Request - ICMPv4-In)" -Verbose
+}
+catch {
+}
+
+# Terminal services and sysprep registry entries
+try {
+ Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0 -Verbose -Force
+ Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 0 -Verbose -Force
+ Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -Value 0 -Verbose -Force
+ Set-ItemProperty -Path 'HKLM:\SYSTEM\Setup\Status\SysprepStatus' -Name 'GeneralizationState' -Value 7 -Verbose -Force
+}
+catch {
+}
+
+# remove Windows Defender
+try {
+ Remove-WindowsFeature -Name Windows-Defender-Features -IncludeManagementTools -ErrorAction SilentlyContinue -Verbose
+}
+catch {
+}
+# Install chocolatey
+try {
+ Set-ExecutionPolicy Bypass; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
+}
+catch {
+ Write-Output "Phase 1 choco install problem, exiting"
+ exit (-1)
+}
#Remove 260 Character Path Limit
if (Test-Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem') {
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem'-name "LongPathsEnabled" -Value 1 -Verbose -Force
}
-# Spectre and Meltdown AV
-if (!(Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat')) {
- New-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat' -Verbose -Force
-}
-Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat'-name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -Value 0 -Verbose -Force
-
-# Spectre and Meltdown Mitigations enable
-Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management'-name "FeatureSettingsOverride" -Value 0 -Verbose -Force
-Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management'-name "FeatureSettingsOverrideMask" -Value 3 -Verbose -Force
-#
Write-Output "End of Phase 1"
exit 0
diff --git a/extra/scripts/phase-1.w10.ps1 b/extra/scripts/phase-1.w10.ps1
index 982f13d..ceaf947 100755
--- a/extra/scripts/phase-1.w10.ps1
+++ b/extra/scripts/phase-1.w10.ps1
@@ -2,31 +2,31 @@ Write-Output "Start of Phase-1 - Enabling RDP, disabling NLA, reset SysprepStatu
# features
-if (Get-WindowsOptionalFeature -online -FeatureName Microsoft-Windows-Subsystem-Linux)
- {Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart}
-else
- {write-output "No feature"}
+#if (Get-WindowsOptionalFeature -online -FeatureName Microsoft-Windows-Subsystem-Linux)
+# {Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart}
+#else
+# {write-output "No feature"}
+#
+#if (Get-WindowsOptionalFeature -online -FeatureName SimpleTCP)
+# {Enable-WindowsOptionalFeature -Online -FeatureName SimpleTCP -NoRestart}
+#else
+# {write-output "No feature"}
+#
+#if (Get-WindowsOptionalFeature -online -FeatureName MicrosoftWindowsPowerShellV2)
+# {Enable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2 -NoRestart}
+#else
+# {write-output "No feature"}
-if (Get-WindowsOptionalFeature -online -FeatureName SimpleTCP)
- {Enable-WindowsOptionalFeature -Online -FeatureName SimpleTCP -NoRestart}
-else
- {write-output "No feature"}
-
-if (Get-WindowsOptionalFeature -online -FeatureName MicrosoftWindowsPowerShellV2)
- {Enable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2 -NoRestart}
-else
- {write-output "No feature"}
-
-if (Get-WindowsOptionalFeature -online -FeatureName NetFx3) {
- if (Test-Path d:\) {
- {Enable-WindowsOptionalFeature -Online -FeatureName NetFx3 -NoRestart -Source:D:\sources\sxs}
- }
- if (Test-Path e:\) {
- {Enable-WindowsOptionalFeature -Online -FeatureName NetFx3 -NoRestart -Source:e:\sources\sxs}
- }
-}
-else
- {write-output "No feature"}
+#if (Get-WindowsOptionalFeature -online -FeatureName NetFx3) {
+# if (Test-Path d:\) {
+# {Enable-WindowsOptionalFeature -Online -FeatureName NetFx3 -NoRestart -Source:D:\sources\sxs}
+# }
+# if (Test-Path e:\) {
+# {Enable-WindowsOptionalFeature -Online -FeatureName NetFx3 -NoRestart -Source:e:\sources\sxs}
+# }
+#}
+#else
+# {write-output "No feature"}
# Firewall rules
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
@@ -71,12 +71,12 @@ if (Test-Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem')
Set-ExecutionPolicy Bypass; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Enable Ansible
-Set-ExecutionPolicy Bypass;Invoke-Expression ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))
+# Set-ExecutionPolicy Bypass;Invoke-Expression ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))
# Spectre and Meltdown AV
-if (!(Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat'))
- {
- New-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat' -Verbose -Force
- }
- Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat'-name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -Value 0 -Verbose -Force
-Write-Output "End of Phase 1"
+# if (!(Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat'))
+# {
+# New-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat' -Verbose -Force
+# }
+# Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat'-name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -Value 0 -Verbose -Force
+# Write-Output "End of Phase 1"
exit 0
\ No newline at end of file
diff --git a/extra/scripts/phase-2.ps1 b/extra/scripts/phase-2.ps1
index c313cd8..11b0876 100755
--- a/extra/scripts/phase-2.ps1
+++ b/extra/scripts/phase-2.ps1
@@ -1,6 +1,12 @@
# Phase 2 - generic and essential stuff
Write-Output "Start of Phase-2"
Set-TimeZone -Id "Central European Standard Time" -Verbose
+ try {
+ Write-Output "Setting high performance power plan"
+ powercfg.exe /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
+ }
+ catch {
+ }
choco feature enable -n allowEmptyChecksums
choco install conemu sysinternals dotnet4.7.2 -y --force
Write-Output "End of Phase-2"
diff --git a/extra/scripts/phase-3.ps1 b/extra/scripts/phase-3.ps1
index 5066eb7..f657c2e 100755
--- a/extra/scripts/phase-3.ps1
+++ b/extra/scripts/phase-3.ps1
@@ -1,14 +1,27 @@
-# Phase 3 - less generic stuff
+# Phase 3 - stuff which is not generic
# Uncomment next line to skip this
+
# exit 0
Write-Output "Start of Phase-3"
+ $puppet_version="5.5.13"
# add your stuff here
# add my myget source
- choco source add -n=public -s"https://www.myget.org/F/public-choco" --priority=10
- choco install puppet-agent --version 5.5.8 -ia '"PUPPET_MASTER_SERVER=foreman.spcph.local"' -y
- Get-Service -name puppet -ErrorAction Silentlycontinue|Stop-Service -Force -ErrorAction Silentlycontinue
- Set-Service -name puppet -StartupType Disabled
- Remove-Item "c:\ProgramData\PuppetLabs\puppet\cache\" -Recurse -Force -ErrorAction Silentlycontinue
- Remove-Item "c:\ProgramData\PuppetLabs\puppet\etc\ssl\" -Recurse -Force -ErrorAction Silentlycontinue
+ try {
+ choco source add -n=public -s"https://www.myget.org/F/public-choco" --priority=10
+ # install puppet/stop/clean
+ choco install puppet-agent --version $puppet_version -ia '"PUPPET_MASTER_SERVER=foreman.spcph.local"' -y
+ }
+ catch {
+ Write-Output "Phase-3 - Install source or install puppet-agent failed"
+ }
+ try {
+ Get-Service -name puppet -ErrorAction Silentlycontinue|Stop-Service -Force -ErrorAction Silentlycontinue
+ Set-Service -name puppet -StartupType Disabled
+ Remove-Item "c:\ProgramData\PuppetLabs\puppet\cache\" -Recurse -Force -ErrorAction Silentlycontinue
+ Remove-Item "c:\ProgramData\PuppetLabs\puppet\etc\ssl\" -Recurse -Force -ErrorAction Silentlycontinue
+ }
+ catch {
+ Write-Output "Phase-3 - Cleaning or stopping "
+ }
Write-Output "End of Phase-3"
exit 0
diff --git a/extra/scripts/phase-5.ps1 b/extra/scripts/phase-5.ps1
new file mode 100644
index 0000000..63bbb5e
--- /dev/null
+++ b/extra/scripts/phase-5.ps1
@@ -0,0 +1,4 @@
+# Post updates entries, not required to do a reboot
+Write-Output "Start Phase 5"
+Write-Output "End Phase 5"
+
diff --git a/extra/scripts/phase-5b.docker.ps1 b/extra/scripts/phase-5b.docker.ps1
index 0489bc4..78a6e1f 100644
--- a/extra/scripts/phase-5b.docker.ps1
+++ b/extra/scripts/phase-5b.docker.ps1
@@ -1,24 +1,33 @@
-# Post updates entries, not required to do a reboot
# Enable docker
$requiredVersion="18.09"
$installCompose = $true
Write-Output "Start Phase 5b-Docker"
try {
- Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
- Update-Module DockerMsftProvider -Force
+ Install-Module -Name DockerMsftProvider -Repository PSGallery -Force -Confirm:$false
+ Update-Module DockerMsftProvider -Force -Confirm:$false
+}
+catch {
+ Write "Phase 5b-docker failed - Install/Update module problem"
+ exit (-1)
+}
+
+try {
Install-Package -Name docker -ProviderName DockerMsftProvider -RequiredVersion $RequiredVersion -Confirm:$false -Force
Set-Service -Name docker -StartupType Automatic
}
catch {
- Write "Phase 5b-docker failed"
+ Write "Phase 5b-docker failed - Install-Package Docker problem"
exit (-1)
}
+
+
if ($installCompose) {
try {
choco install docker-compose -y
}
catch {
+ Write "Phase 5b-docker failed - Install docker-compose problem"
}
}
Write-Output "End Phase 5b"
diff --git a/extra/scripts/phase-5b.ps1 b/extra/scripts/phase-5b.ps1
deleted file mode 100644
index 1ec656f..0000000
--- a/extra/scripts/phase-5b.ps1
+++ /dev/null
@@ -1,5 +0,0 @@
-# Post updates entries, not required to do a reboot
-
-# Spectre meltdown
-Write-Output "Start Phase 5b"
-Write-Output "End Phase 5b"
diff --git a/extra/scripts/virtualbox/bootstrap.ps1 b/extra/scripts/virtualbox/bootstrap.ps1
index 238fec5..dd20657 100755
--- a/extra/scripts/virtualbox/bootstrap.ps1
+++ b/extra/scripts/virtualbox/bootstrap.ps1
@@ -9,8 +9,16 @@ New-Item C:\Windows\Panther\Unattend -Type Directory
New-Item c:\Scripts -Type Directory
Copy-Item a:\unattend.xml C:\Windows\Panther\Unattend\ -Force
New-Item -Path 'C:\Windows\Setup\Scripts' -ItemType Directory -Force
-Copy-Item a:\oracle-cert.cer c:\Scripts -Force
-certutil -addstore -f "TrustedPublisher" c:\Scripts\oracle-cert.cer
+Write-Output "Bootstrap: Copy certificates"
+try {
+ Copy-Item a:\vbox-sha256.cer c:\Scripts -Force
+ Copy-Item a:\vbox-sha1.cer c:\Scripts -Force
+ certutil -addstore -f "TrustedPublisher" c:\Scripts\vbox-sha256.cer
+ certutil -addstore -f "TrustedPublisher" c:\Scripts\vbox-sha1.cer
+}
+catch {
+ Write-Output "Bootstrap failed"
+}
# Get network connections
$networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}'))
diff --git a/extra/scripts/virtualbox/generalize.ps1 b/extra/scripts/virtualbox/generalize.ps1
index 6d38c98..463d059 100755
--- a/extra/scripts/virtualbox/generalize.ps1
+++ b/extra/scripts/virtualbox/generalize.ps1
@@ -1,21 +1,31 @@
-Write-Output "Starting Phase 5a - generalize and prepare sysprep scripts"
+# Generalize
+$vboxguestinstalled=$false
+Write-Output "Starting Phase 5a - generalize and prepare sysprep scripts"
New-Item -Path 'C:\Windows\Setup\Scripts' -ItemType Directory -Force
+
# Installing Guest Additions
-Write-Host 'Installing Guest Additions or Parallels Tools'
+Write-Host 'Installing Virtualbox Guest Additions'
if (Test-Path d:\VBoxWindowsAdditions.exe) {
- Write-Host "Mounting Drive with VBoxWindowsAdditions"
+ Write-Host "Mounting Drive D: with VBoxWindowsAdditions"
& d:\VBoxWindowsAdditions.exe /S
Write-Host "Sleeping for 60 seconds so we are sure the tools are installed before reboot"
Start-Sleep -s 60
+ $vboxguestinstalled=$true
}
if (Test-Path e:\VBoxWindowsAdditions.exe) {
- Write-Host "Mounting Drive with VBoxWindowsAdditions"
+ Write-Host "Mounting Drive E: with VBoxWindowsAdditions"
& E:\VBoxWindowsAdditions.exe /S
Write-Host "Sleeping for 60 seconds so we are sure the tools are installed before reboot"
Start-Sleep -s 60
+ $vboxguestinstalled=$true
}
-
Write-Output "Ending Phase 5a - generalize and prepare sysprep scripts"
-exit 0
\ No newline at end of file
+if ($vboxguestinstalled) {
+ exit 0
+}
+else {
+ Write-Output "Virtualbox Guest Addition Failed - exiting"
+ exit (-1)
+}
diff --git a/extra/scripts/virtualbox/oracle-cert.cer b/extra/scripts/virtualbox/oracle-cert.cer
deleted file mode 100644
index d1bc63f..0000000
Binary files a/extra/scripts/virtualbox/oracle-cert.cer and /dev/null differ
diff --git a/extra/scripts/virtualbox/vbox-sha1.cer b/extra/scripts/virtualbox/vbox-sha1.cer
new file mode 100644
index 0000000..e47fb25
Binary files /dev/null and b/extra/scripts/virtualbox/vbox-sha1.cer differ
diff --git a/extra/scripts/virtualbox/vbox-sha256.cer b/extra/scripts/virtualbox/vbox-sha256.cer
new file mode 100644
index 0000000..1675ee3
Binary files /dev/null and b/extra/scripts/virtualbox/vbox-sha256.cer differ
diff --git a/hv_centos75_g2.cmd b/hv_centos75_g2.cmd
deleted file mode 100755
index ff7be06..0000000
--- a/hv_centos75_g2.cmd
+++ /dev/null
@@ -1,3 +0,0 @@
-set PACKER_LOG=0
-packer validate .\templates\hv_centos75_g2.json
-packer build .\templates\hv_centos75_g2.json
diff --git a/hv_win2019_dc_g2.cmd b/hv_win2019_dc_g2.cmd
new file mode 100755
index 0000000..7d760dc
--- /dev/null
+++ b/hv_win2019_dc_g2.cmd
@@ -0,0 +1,3 @@
+set PACKER_LOG=0
+packer validate .\templates\hv_win2019_dc_g2.json
+packer build -force .\templates\hv_win2019_dc_g2.json
\ No newline at end of file
diff --git a/hv_win2019_std_g2.cmd b/hv_win2019_std_g2.cmd
new file mode 100755
index 0000000..5dc17eb
--- /dev/null
+++ b/hv_win2019_std_g2.cmd
@@ -0,0 +1,3 @@
+set PACKER_LOG=0
+packer validate .\templates\hv_win2019_std_g2.json
+packer build -force .\templates\hv_win2019_std_g2.json
\ No newline at end of file
diff --git a/templates/hv_centos76_g2.json b/templates/hv_centos76_g2.json
index c0f242f..57c4c92 100755
--- a/templates/hv_centos76_g2.json
+++ b/templates/hv_centos76_g2.json
@@ -28,7 +28,7 @@
],
"guest_additions_mode":"disable",
"enable_secure_boot": false,
- "output_directory": "output-centos76"
+ "output_directory": "{{ user `output_directory` }}"
}
],
"provisioners": [
@@ -83,7 +83,7 @@
"chmod +x /tmp/install",
"cd /tmp",
"/tmp/install /tmp/scvmmguestagent.1.0.3.1022.x64.tar"
- ],
+ ],
"inline_shebang": "/bin/sh -x",
"type": "shell"
},
@@ -91,18 +91,20 @@
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"chmod +x /tmp/provision.sh",
- "chmod +x /tmp/prepare_neofetch.sh",
"/tmp/provision.sh",
- "/tmp/prepare_neofetch.sh"
- ],
+ "reboot"
+ ],
"inline_shebang": "/bin/sh -x",
- "type": "shell"
+ "type": "shell",
+ "expect_disconnect": true
},
{
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
+ "chmod +x /tmp/prepare_neofetch.sh",
+ "/tmp/prepare_neofetch.sh",
"chmod +x /usr/local/bin/uefi.sh"
- ],
+ ],
"inline_shebang": "/bin/sh -x",
"type": "shell"
},
@@ -132,6 +134,7 @@
"iso_checksum": "918975cdf947e858c9a0c77d6b90a9a56d9977f3a4496a56437f46f46200cf71",
"switch_name": "",
"vm_name": "packer-centos76-g2",
- "vlan_id": ""
+ "vlan_id": "",
+ "output_directory": "output-centos76"
}
}
\ No newline at end of file
diff --git a/templates/hv_centos75_g2.json b/templates/hv_centos76_g2_vagrant.json
similarity index 74%
rename from templates/hv_centos75_g2.json
rename to templates/hv_centos76_g2_vagrant.json
index c0b54e8..75393b9 100755
--- a/templates/hv_centos75_g2.json
+++ b/templates/hv_centos76_g2_vagrant.json
@@ -28,7 +28,7 @@
],
"guest_additions_mode":"disable",
"enable_secure_boot": false,
- "output_directory": "output-centos75"
+ "output_directory": "{{ user `output_directory` }}"
}
],
"provisioners": [
@@ -62,6 +62,11 @@
"source": "extra/files/gen2-centos/zeroing.sh",
"destination": "/tmp/zeroing.sh"
},
+ {
+ "type": "file",
+ "source": "extra/files/gen2-centos/vagrant.sh",
+ "destination": "/tmp/vagrant.sh"
+ },
{
"type": "file",
"source": "extra/files/gen2-centos/uefi.sh",
@@ -69,12 +74,12 @@
},
{
"type": "file",
- "source": "extra/files/gen2-centos/scagent/1.0.2.1075/scvmmguestagent.1.0.2.1075.x64.tar",
- "destination": "/tmp/scvmmguestagent.1.0.2.1075.x64.tar"
+ "source": "extra/files/gen2-centos/scagent/1.0.3.1022/scvmmguestagent.1.0.3.1022.x64.tar",
+ "destination": "/tmp/scvmmguestagent.1.0.3.1022.x64.tar"
},
{
"type": "file",
- "source": "extra/files/gen2-centos/scagent/1.0.2.1075/install",
+ "source": "extra/files/gen2-centos/scagent/1.0.3.1022/install",
"destination": "/tmp/install"
},
{
@@ -82,8 +87,8 @@
"inline": [
"chmod +x /tmp/install",
"cd /tmp",
- "/tmp/install /tmp/scvmmguestagent.1.0.2.1075.x64.tar"
- ],
+ "/tmp/install /tmp/scvmmguestagent.1.0.3.1022.x64.tar"
+ ],
"inline_shebang": "/bin/sh -x",
"type": "shell"
},
@@ -91,18 +96,22 @@
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
"chmod +x /tmp/provision.sh",
- "chmod +x /tmp/prepare_neofetch.sh",
"/tmp/provision.sh",
- "/tmp/prepare_neofetch.sh"
- ],
+ "reboot"
+ ],
"inline_shebang": "/bin/sh -x",
- "type": "shell"
+ "type": "shell",
+ "expect_disconnect": true
},
{
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
"inline": [
+ "chmod +x /tmp/prepare_neofetch.sh",
+ "chmod +x /tmp/vagrant.sh",
+ "/tmp/prepare_neofetch.sh",
+ "/tmp/vagrant.sh",
"chmod +x /usr/local/bin/uefi.sh"
- ],
+ ],
"inline_shebang": "/bin/sh -x",
"type": "shell"
},
@@ -126,12 +135,23 @@
"pause_before": "60s"
}
],
+ "post-processors": [
+ {
+ "type": "vagrant",
+ "keep_input_artifact": true,
+ "output": "{{ user `output_vagrant` }}",
+ "vagrantfile_template": "{{ user `vagrantfile_template` }}"
+ }
+ ],
"variables": {
- "iso_url": "http://mirror-pl.kielcetechnologypark.net/centos/7/isos/x86_64/CentOS-7-x86_64-Everything-1804.iso",
+ "iso_url": "http://mirror-pl.kielcetechnologypark.net/centos/7/isos/x86_64/CentOS-7-x86_64-Everything-1810.iso",
"iso_checksum_type": "sha256",
- "iso_checksum": "99723c8b87dcec21df8aed23de1eb810346d42cfd2a3fafafe70a68296053417",
+ "iso_checksum": "918975cdf947e858c9a0c77d6b90a9a56d9977f3a4496a56437f46f46200cf71",
"switch_name": "",
+ "vm_name": "packer-centos76-g2",
"vlan_id": "",
- "vm_name": "packer-centos75-g2"
+ "output_directory": "output-centos76",
+ "output_vagrant": "./vbox/packer-centos-76-g2.box",
+ "vagrantfile_template": "./vagrant/hv_centos76_g2.template"
}
}
\ No newline at end of file
diff --git a/templates/hv_win2016_1803_g2.json b/templates/hv_win2016_1803_g2.json
index f522190..e2dc804 100755
--- a/templates/hv_win2016_1803_g2.json
+++ b/templates/hv_win2016_1803_g2.json
@@ -7,7 +7,7 @@
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"temp_path": ".",
- "disk_size": "70000",
+ "disk_size": "{{ user `disk_size`}}",
"communicator": "winrm",
"winrm_username": "Administrator",
"winrm_password": "password",
@@ -23,11 +23,11 @@
"boot_command": [
"aaaa"
],
- "output_directory": "output-windows-1803-g2",
+ "output_directory": "{{ user `output_directory`}}",
"guest_additions_mode":"disable",
- "enable_secure_boot":true,
+ "enable_secure_boot":false,
"secondary_iso_images": [
- "./extra/files/gen2-1803/secondary1803.iso"
+ "{{ user `secondary_iso_image`}}"
]
}
],
@@ -56,7 +56,9 @@
},
{
"type": "windows-restart",
- "restart_timeout": "2h"
+ "restart_timeout": "2h",
+ "pause_before": "30s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"type": "powershell",
@@ -80,7 +82,7 @@
{
"type": "windows-restart",
"restart_timeout": "2h",
- "pause_before": "180s",
+ "pause_before": "120s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
@@ -96,6 +98,12 @@
"pause_before": "120s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-5.ps1"
+ },
{
"type": "powershell",
"elevated_user": "Administrator",
@@ -105,7 +113,7 @@
{
"type": "windows-restart",
"restart_timeout": "2h",
- "pause_before": "120s",
+ "pause_before": "30s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
@@ -129,6 +137,9 @@
"iso_checksum": "1f396b448ae0a68e5a2f694b0afabb61498e20a5df38c874aacb4e940a661b61",
"switch_name": "",
"vlan_id": "",
- "vm_name": "packer-windows2016-1803-g2"
+ "vm_name": "packer-windows2016-1803-g2",
+ "disk_size": "70000",
+ "output_directory": "output-windows-1803-g2",
+ "secondary_iso_image": "./extra/files/gen2-1803/secondary1803.iso"
}
}
\ No newline at end of file
diff --git a/templates/hv_win2016_1809_g2.json b/templates/hv_win2016_1809_g2.json
index e3e6af2..08427a2 100755
--- a/templates/hv_win2016_1809_g2.json
+++ b/templates/hv_win2016_1809_g2.json
@@ -7,7 +7,7 @@
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"temp_path": ".",
- "disk_size": "70000",
+ "disk_size": "{{ user `disk_size`}}",
"communicator": "winrm",
"winrm_username": "Administrator",
"winrm_password": "password",
@@ -23,11 +23,11 @@
"boot_command": [
"aaaa"
],
- "output_directory": "output-windows-1809-g2",
+ "output_directory": "{{ user `output_directory`}}",
"guest_additions_mode":"disable",
- "enable_secure_boot":true,
+ "enable_secure_boot":false,
"secondary_iso_images": [
- "./extra/files/gen2-1809/secondary1809.iso"
+ "{{ user `secondary_iso_image`}}"
]
}
],
@@ -56,7 +56,9 @@
},
{
"type": "windows-restart",
- "restart_timeout": "2h"
+ "restart_timeout": "2h",
+ "pause_before": "30s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"type": "powershell",
@@ -80,7 +82,7 @@
{
"type": "windows-restart",
"restart_timeout": "2h",
- "pause_before": "180s",
+ "pause_before": "120s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
@@ -96,6 +98,12 @@
"pause_before": "120s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-5.ps1"
+ },
{
"type": "powershell",
"elevated_user": "Administrator",
@@ -105,7 +113,7 @@
{
"type": "windows-restart",
"restart_timeout": "2h",
- "pause_before": "120s",
+ "pause_before": "30s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
@@ -129,6 +137,9 @@
"iso_checksum": "35057365e8faef0afa32d3302c60d1ae21585db0eea76ade6be6eec99ea4fe72",
"switch_name": "",
"vlan_id": "",
- "vm_name": "packer-windows2016-1809-g2"
+ "vm_name": "packer-windows2016-1809-g2",
+ "disk_size": "70000",
+ "output_directory": "output-windows-1809-g2",
+ "secondary_iso_image": "./extra/files/gen2-1809/secondary1809.iso"
}
}
\ No newline at end of file
diff --git a/templates/hv_win2016_g2.json b/templates/hv_win2016_g2.json
index ff6e65c..a6c2c84 100755
--- a/templates/hv_win2016_g2.json
+++ b/templates/hv_win2016_g2.json
@@ -2,12 +2,12 @@
"builders": [
{
"type": "hyperv-iso",
- "vm_name": "packer-windows2016-g2",
+ "vm_name": "{{ user `vm_name` }}",
"iso_url": "{{ user `iso_url` }}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"temp_path": ".",
- "disk_size": "70000",
+ "disk_size": "{{ user `disk_size`}}",
"communicator": "winrm",
"winrm_username": "Administrator",
"winrm_password": "password",
@@ -21,13 +21,13 @@
"vlan_id": "{{user `vlan_id`}}",
"boot_wait": "0s",
"boot_command": [
- "a"
+ "aaaa"
],
- "output_directory": "output-windows-g2",
+ "output_directory": "{{ user `output_directory`}}",
"guest_additions_mode":"disable",
- "enable_secure_boot":true,
+ "enable_secure_boot":false,
"secondary_iso_images": [
- "./extra/files/gen2-2016/secondary.iso"
+ "{{ user `secondary_iso_image`}}"
]
}
],
@@ -57,7 +57,7 @@
{
"type": "windows-restart",
"restart_timeout": "2h",
- "pause_before": "180s",
+ "pause_before": "120s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
@@ -69,43 +69,40 @@
{
"type": "windows-restart",
"restart_timeout": "2h",
- "pause_before": "180s",
+ "pause_before": "120s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"type": "powershell",
"elevated_user": "Administrator",
"elevated_password": "password",
- "script": "./extra/scripts/windows-updates.ps1"
+ "script": "./extra/scripts/windows-updates.ps1",
+ "pause_before": "120s"
},
{
"type": "windows-restart",
"restart_timeout": "2h",
- "pause_before": "180s",
+ "pause_before": "120s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"type": "powershell",
"elevated_user": "Administrator",
"elevated_password": "password",
- "script": "./extra/scripts/windows-updates.ps1" },
+ "script": "./extra/scripts/windows-updates.ps1",
+ "pause_before": "120s"
+ },
{
"type": "windows-restart",
"restart_timeout": "2h",
- "pause_before": "180s",
+ "pause_before": "120s",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"type": "powershell",
"elevated_user": "Administrator",
"elevated_password": "password",
- "script": "./extra/scripts/windows-updates.ps1"
- },
- {
- "type": "windows-restart",
- "restart_timeout": "2h",
- "pause_before": "180s",
- "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
+ "script": "./extra/scripts/phase-5.ps1"
},
{
"type": "powershell",
@@ -127,6 +124,10 @@
"iso_checksum_type": "sha256",
"iso_checksum": "47919ce8b4993f531ca1fa3f85941f4a72b47ebaa4d3a321fecf83ca9d17e6b8",
"switch_name": "",
- "vlan_id": ""
+ "vlan_id": "",
+ "vm_name": "packer-windows2016-g2",
+ "disk_size": "70000",
+ "output_directory": "output-windows-g2",
+ "secondary_iso_image": "./extra/files/gen2-2016/secondary.iso"
}
}
\ No newline at end of file
diff --git a/templates/hv_win2019_dc_g2.json b/templates/hv_win2019_dc_g2.json
new file mode 100755
index 0000000..4dab4d5
--- /dev/null
+++ b/templates/hv_win2019_dc_g2.json
@@ -0,0 +1,133 @@
+{
+ "builders": [
+ {
+ "type": "hyperv-iso",
+ "vm_name": "{{ user `vm_name` }}",
+ "iso_url": "{{ user `iso_url` }}",
+ "iso_checksum_type": "{{user `iso_checksum_type`}}",
+ "iso_checksum": "{{user `iso_checksum`}}",
+ "temp_path": ".",
+ "disk_size": "{{ user `disk_size`}}",
+ "communicator": "winrm",
+ "winrm_username": "Administrator",
+ "winrm_password": "password",
+ "winrm_timeout": "8h",
+ "shutdown_timeout": "30m",
+ "ram_size": 4096,
+ "enable_dynamic_memory": "true",
+ "cpu": 4,
+ "generation": 2,
+ "switch_name": "{{user `switch_name`}}",
+ "vlan_id": "{{user `vlan_id`}}",
+ "boot_wait": "0s",
+ "boot_command": [
+ "aaaa"
+ ],
+ "output_directory": "{{ user `output_directory`}}",
+ "guest_additions_mode":"disable",
+ "enable_secure_boot":false,
+ "secondary_iso_images": [
+ "{{ user `secondary_iso_image`}}"
+ ]
+ }
+ ],
+ "provisioners": [
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-1.ps1"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "1h"
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-2.ps1"
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-3.ps1"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "2h",
+ "pause_before": "120s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/windows-updates.ps1"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "2h",
+ "pause_before": "120s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/windows-updates.ps1",
+ "pause_before": "120s"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "2h",
+ "pause_before": "120s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/windows-updates.ps1",
+ "pause_before": "120s"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "2h",
+ "pause_before": "120s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-5.ps1"
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/windows-compress.ps1"
+ },
+ {
+ "type": "powershell",
+ "inline": [
+ "Write-Output Phase-5-Deprovisioning",
+ "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
+ "& $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /shutdown /quiet"
+ ]
+ }
+ ],
+ "variables": {
+ "iso_url": ".\\iso\\SW_DVD9_Win_Server_STD_CORE_2019_1809.1_64Bit_English_DC_STD_MLF_X22-02970.ISO",
+ "iso_checksum_type": "sha256",
+ "iso_checksum": "47ec5da25b232b2e7a1c10f3ee22b0f0e68eb1ea4d338e9d1d8f9db30a8f789e",
+ "switch_name": "",
+ "vlan_id": "",
+ "vm_name": "packer-windows2019dc-g2",
+ "disk_size": "80000",
+ "output_directory": "output-windows-2019dc-g2",
+ "secondary_iso_image": "./extra/files/gen2-2019/dc/secondary.iso"
+ }
+}
\ No newline at end of file
diff --git a/templates/hv_win2019_std_g2.json b/templates/hv_win2019_std_g2.json
new file mode 100755
index 0000000..d540358
--- /dev/null
+++ b/templates/hv_win2019_std_g2.json
@@ -0,0 +1,133 @@
+{
+ "builders": [
+ {
+ "type": "hyperv-iso",
+ "vm_name": "{{ user `vm_name` }}",
+ "iso_url": "{{ user `iso_url` }}",
+ "iso_checksum_type": "{{user `iso_checksum_type`}}",
+ "iso_checksum": "{{user `iso_checksum`}}",
+ "temp_path": ".",
+ "disk_size": "{{ user `disk_size`}}",
+ "communicator": "winrm",
+ "winrm_username": "Administrator",
+ "winrm_password": "password",
+ "winrm_timeout": "8h",
+ "shutdown_timeout": "30m",
+ "ram_size": 4096,
+ "enable_dynamic_memory": "true",
+ "cpu": 4,
+ "generation": 2,
+ "switch_name": "{{user `switch_name`}}",
+ "vlan_id": "{{user `vlan_id`}}",
+ "boot_wait": "0s",
+ "boot_command": [
+ "aaaa"
+ ],
+ "output_directory": "{{ user `output_directory`}}",
+ "guest_additions_mode":"disable",
+ "enable_secure_boot":false,
+ "secondary_iso_images": [
+ "{{ user `secondary_iso_image`}}"
+ ]
+ }
+ ],
+ "provisioners": [
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-1.ps1"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "1h"
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-2.ps1"
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-3.ps1"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "2h",
+ "pause_before": "120s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/windows-updates.ps1"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "2h",
+ "pause_before": "120s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/windows-updates.ps1",
+ "pause_before": "120s"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "2h",
+ "pause_before": "120s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/windows-updates.ps1",
+ "pause_before": "120s"
+ },
+ {
+ "type": "windows-restart",
+ "restart_timeout": "2h",
+ "pause_before": "120s",
+ "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/phase-5.ps1"
+ },
+ {
+ "type": "powershell",
+ "elevated_user": "Administrator",
+ "elevated_password": "password",
+ "script": "./extra/scripts/windows-compress.ps1"
+ },
+ {
+ "type": "powershell",
+ "inline": [
+ "Write-Output Phase-5-Deprovisioning",
+ "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
+ "& $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /shutdown /quiet"
+ ]
+ }
+ ],
+ "variables": {
+ "iso_url": ".\\iso\\SW_DVD9_Win_Server_STD_CORE_2019_1809.1_64Bit_English_DC_STD_MLF_X22-02970.ISO",
+ "iso_checksum_type": "sha256",
+ "iso_checksum": "47ec5da25b232b2e7a1c10f3ee22b0f0e68eb1ea4d338e9d1d8f9db30a8f789e",
+ "switch_name": "",
+ "vlan_id": "",
+ "vm_name": "packer-windows2019-g2",
+ "disk_size": "80000",
+ "output_directory": "output-windows-2019-g2",
+ "secondary_iso_image": "./extra/files/gen2-2019/std/secondary.iso"
+ }
+}
\ No newline at end of file
diff --git a/vagrant/hv_centos76_g2.template b/vagrant/hv_centos76_g2.template
new file mode 100644
index 0000000..73759ef
--- /dev/null
+++ b/vagrant/hv_centos76_g2.template
@@ -0,0 +1,27 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.require_version ">= 1.6.2"
+
+Vagrant.configure("2") do |config|
+ config.vm.define "vagrant-centos76"
+ config.vm.box = "centos76"
+ config.vm.communicator = "ssh"
+ config.vm.synced_folder ".", "/vagrant", type: "rsync", disabled: "true"
+
+ # Admin user name and password
+ config.ssh.username = "vagrant"
+ config.ssh.password = "vagrant"
+ config.vm.guest = :redhat
+
+# config.vm.provider "hyperv" do |h|
+# h.vm_integration_services = {
+# guest_service_interface: true,
+# heartbeat: true,
+# key_value_pair_exchange: true,
+# shutdown: true,
+# time_synchronization: true,
+# vss: boolean
+# }
+# end
+ end
diff --git a/vagrant_hv_centos76_g2.cmd b/vagrant_hv_centos76_g2.cmd
new file mode 100755
index 0000000..a305938
--- /dev/null
+++ b/vagrant_hv_centos76_g2.cmd
@@ -0,0 +1,3 @@
+set PACKER_LOG=0
+packer validate .\templates\hv_centos76_g2_vagrant.json
+packer build -var "switch_name=Default" .\templates\hv_centos76_g2_vagrant.json