Skip to content

Commit

Permalink
Changed the GH exam topic
Browse files Browse the repository at this point in the history
  • Loading branch information
ibeerens committed Mar 25, 2024
1 parent 6f2ce34 commit 183c2ce
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
title: "Build a Windows 10 image with Packer using VMware Workstation"
date: "2022-05-31T20:04:33.000Z"
categories:
- "iac"
- "packer"
- vmware workstation
- packer
- windows
tags:
- "packer"
- "windows"
- vmware workstation
- packer
- windows
author: Ivo Beerens
url: /2022/05/31/build-a-windows-10-image-with-packer-using-vmware-workstation/
---
Expand All @@ -18,26 +20,37 @@ With Packer, the VMware-iso builder is used for creating images with VMware Work
## **Pre-requisites**

- Windows a 10 ISO file. You can use this [link](https://www.ivobeerens.nl/2021/05/19/quick-tip-download-the-latest-windows-10-iso-file/) for downloading the latest Windows 10 ISO for example
- Install VMware Workstation. I use VMware Workstation Pro 16.x
- The newly created image must be able to access the internet for  downloading the latest VMware Tools version
- During my first deployment, the following build issue occurred Build "**Could not determine network mappings from files in the path: C:/Program Files (x86)/VMware/VMware Workstation**". Colin Westwater of vGemba.net has blogged about a solution that can be found here, [link](https://www.vgemba.net/VMware/Packer-Workstation-Error/).
- Install VMware Workstation. I use **VMware Workstation Pro 17.x**
- The newly created image must be able to access the internet for downloading the latest VMware Tools version
- During my first deployment, the following build issue occurred Build "**Could not determine network mappings from files in the path: C:/Program Files (x86)/VMware/VMware Workstation**". Colin Westwater of vGemba.net has blogged about a solution that can be found here, [**link**](https://www.vgemba.net/vmware/Packer-Workstation-Error/).

The solution to solve this error is:

>1. In Workstation go to `Edit...Virtual Network Editor`
>2. Click Change `Settings`
>3. Don’t change anything, just click `OK` <br>
>Now if you look in `C:\ProgramData\VMware` there is a new file called `netmap.conf`
- Use NAT in VMware Workstation.
- Install Hashicorp Packer, see [Download the latest Hashicorp Terraform, Packer, and Vault bits](https://www.ivobeerens.nl/2023/09/22/download-the-latest-hashicorp-terraform-packer-and-vault-bits/)
for installing Packer.

## **Steps**

- Run the following PowerShell script ([link](https://raw.githubusercontent.com/ibeerens/Packer/main/workstation/windows10/download.ps1)). This script does the following things:
- Create a download folder such as c:\Packer (line 6-17)
- Download the latest Packer version and unzip the package (line 19-30)
- Download my Github Packer repository to the local download folder (line 35-39)
- Create within the download folder the Packer folder structure (line 41-45)
- Create a download folder such as `c:\Packer\win10`
- Download my Github Packer repository to the local download folder
- Create within the download folder the Packer folder structure

The script looks like this:

```powershell
# $ErrorActionPreference = "SilentlyContinue"
# Enable TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Variables
$downloadfolder = 'C:\packer\'
$downloadfolder = 'C:\packer\win10\'
$github = 'https://github.com/ibeerens/Packer/archive/refs/heads/main.zip'
# Create Folder
Expand All @@ -50,19 +63,6 @@ else {
Write-Verbose "Folder '$downloadfolder' already exists."
}
# Download the latest Packer version
$product='packer'
$packurl = Invoke-WebRequest -Uri https://www.$product.io/downloads.html | Select-Object -Expand links | Where-Object href -match "//releases\.hashicorp\.com/$product/\d.*/$product_.*_windows_amd64\.zip$" | Select-Object -Expand href
$packdown = $packurl | Split-Path -Leaf
$packdownload = $downloadfolder + $packdown
$webclient = New-object -TypeName System.Net.WebClient
$webclient.DownloadFile($packurl, $packdownload)
# Unzip Packer
Expand-Archive $packdownload -DestinationPath $downloadfolder
# Remove the Packer ZIP file
Remove-Item $packdownload
# Go to the Packer download folder
Set-Location $downloadfolder
Expand All @@ -73,13 +73,13 @@ Expand-Archive ${downloadfolder}packer.zip -DestinationPath $downloadfolder
Remove-Item -Path ${downloadfolder}packer.zip
# Create the folder structure
Move-Item ${downloadfolder}Packer-main\workstation\windows10\setup -Destination $downloadfolder
Move-Item ${downloadfolder}packer-main\workstation\windows10\setup -Destination $downloadfolder
Move-Item ${downloadfolder}Packer-main\workstation\windows10\*.* -Destination $downloadfolder
# Remove the Github structure
Remove-Item -Path ${downloadfolder}Packer-main -Recurse -Confirm:$false -Force
```

- Browse to the download folder
- Browse to the download folder location
- Open the "win10-std-.auto-pkvars.hcl" file and edit the variables for your needs such as:
- Line 2: The VM name
- Line 17: The ISO location
Expand All @@ -93,48 +93,54 @@ vm_firmware = "bios"
vm_cdrom_type = "ide"
vm_cpus = "2"
vm_cores = "1"
vm_memory = "2048"
vm_memory = "4096"
vm_disk_controller_type = "nvme"
vm_disk_size = "32768"
vm_disk_size = "65536"
vm_network_adapter_type = "e1000e"
// Use the NAT Network
vm_network = "VMnet8"
vm_hardwareversion = "19"

// Removeable media
win10_iso = "c:/iso/en-us_windows_10_business_editions_version_21h2_x64_dvd_ce067768.iso"
win10_iso = "c:/iso/feb2024/en-us_windows_10_business_editions_version_22h2_updated_feb_2024_x64_dvd_732d1707.iso"
// In Powershell use the "get-filehash" command to find the checksum of the ISO
win10_iso_checksum = "1323FD1EF0CBFD4BF23FA56A6538FF69DD410AD49969983FEE3DF936A6C811C5"
win10_iso_checksum = "E433ADA123A50DBDEE946FEA5B34BD40038891F5C0ADBB1D72CACF5A633AD391"
```

- Open the "autounattend.xml" file in the setup folder and check and edit the following lines as needed:
- Language and keyboard settings
- Line 84: Administrator Password (must be the same as the winrm_password)
- Line 92: Autologon Password (must be the same as the winrm_password)
- Line 141: The ComputerName
- Open the `autounattend.xml` file in the setup folder and check and edit the following lines as needed:
- Language and keyboard settings
- Line 84: Administrator Password (must be the same as the `winrm_password`)
- Line 92: Autologon Password (must be the same as the `winrm_password`)
- Line 141: The ComputerName

- Edit the build.ps1 file and check the following lines:
- Line 2: Packer folder location
- Line 14: The winrm\_password matches the administrator password in the autounattended.xml file
- Edit the `build.ps1` file and check the following lines:
- Line 2: Packer folder location
- Line 14: The `winrm_password` matches the administrator password in the `autounattended.xml` file

```powershell
# Variables
$downloadfolder = 'C:\packer\'
# Go to the Packer download folder
Set-Location $downloadfolder
$downloadfolder = 'C:\packer\win10\'
$packer_config = "windows.json.pkr.hcl" #Packer config file
$packer_variable = "windows.auto.pkrvars.hcl" # Packer variable file
# Show Packer Version
.\packer.exe -v
packer.exe -v
# Download Packer plugins
.\packer.exe init "${downloadfolder}windows.json.pkr.hcl"
packer.exe init "$downloadfolder$packer_config"
# Packer Format configuration files (.pkr.hcl) and variable files (.pkrvars.hcl) are updated.
packer.exe fmt -var-file="$downloadfolder$packer_variable" "$downloadfolder$packer_config"
# Packer validate
# packer.exe validate .
# Packer build
.\packer.exe build -force -var-file="${downloadfolder}win10-std.auto.pkrvars.hcl" -var "winrm_username=administrator" -var "winrm_password=ThisisagoodPassword!" "${downloadfolder}windows.json.pkr.hcl"
# .\packer.exe build -force -var-file="${$win11_downloadfolder}${packer_variable}" "${$win11_downloadfolder}${packer_config}"
packer.exe build -force -var-file="$downloadfolder$packer_variable" -var "winrm_username=administrator" -var "winrm_password=ThisisagoodPassword!" "$downloadfolder$packer_config"
```

- Execute the "build.ps1" file with PowerShell to start the Packer image build process.
- Run the "build.ps1" file with PowerShell to start the Packer image build process.

[![](images/PackerRun-300x164.jpg)](images/PackerRun.jpg)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
title: "How to install Windows 11 on VMware Workstation"
date: "2022-10-17T07:26:48.000Z"
categories:
- "VMware-workstation"
- "windows-11"
- VMware-workstation
- windows 11
- packer
tags:
- "VMware-workstation"
- "windows-11"
- VMware Workstation
- windows-11
- packer
author: Ivo Beerens
url: /2022/10/17/how-to-install-windows-11-on-vmware-workstation/
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ I created a PowerShell Script that downloads the latest version of Terraform, Pa
.NOTES Changed: September 10, 2023
.NOTES Reason: Creation
#>
#Enable TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#Speed up the Invoke-Webrequest command
$ProgressPreference = 'SilentlyContinue'
#Variables
$temp_folder = "c:\install\" #Temp download location
$hashicorp_destination = "c:\install\hashicorp\" #Path for storing the Hashicorp binaries
$temp_folder = "c:\progs\" #Temp download location
$hashicorp_destination = "c:\progs\hashicorp\" #Path for storing the Hashicorp binaries
#Check if the temp folder exists
If(!(test-path -PathType container $hashicorp_destination )) {
New-Item -ItemType Directory -Path $hashicorp_destination
New-Item -ItemType Directory -Path $hashicorp_destination
}
#Jump to the download folder
Set-Location $hashicorp_destination
Set-Location $hashicorp_destination
Function Download-Hashicorp {
param (
[string]$product,
Expand All @@ -65,18 +65,18 @@ Function Download-Hashicorp {
throw $_.Exception.Message
}
}
#Download Packer, Vault, and Terraform
$products = @{
'packer' = 'https://developer.hashicorp.com/packer/downloads'
'vault' = 'https://developer.hashicorp.com/vault/downloads'
'terraform' = 'https://developer.hashicorp.com/terraform/downloads'
'packer' = 'https://developer.hashicorp.com/packer/install'
'vault' = 'https://developer.hashicorp.com/vault/install'
'terraform' = 'https://developer.hashicorp.com/terraform/install'
}
foreach ($product in $products.GetEnumerator()) {
Download-Hashicorp -product $product.Name -url $product.Value
}
##Add the Hashicorp binary folder to the system environment variable path
Write-Host "............ Add folder to path ............" -ForegroundColor Green
[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";" + $hashicorp_destination, [EnvironmentVariableTarget]::User)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ In january 2024 GitHub launched his certification program. There are 4 certifica
- **GitHub Advanced Security (GHAS)**. Designed to teach you how to secure your code with advanced security features at every stage of your development lifecycle. GHAS is specific to GitHub Enterprise!
- **GitHub Administration**. Designed to teach you everything you need to maintain a healthy, robust, and secure GitHub environment that supports the needs of your organization.

The first exam I prepare for is the **GitHub Foundations** exam.
![ghfoundations](images/ghfoundations.png)
The first exam I prepared for is the **GitHub Foundations** exam.

Here is a collection of resources to prepare for the GitHub Foundations exam.
![ghfoundations](images/ghfoundations.jpeg)

I passed the exam on march 23, 2024.

Here is a collection o# f resources I used to prepare for the GitHub Foundations exam.

|**Name** | **Description** | **Link** |
| --- | :---: | --- |
Expand Down

0 comments on commit 183c2ce

Please sign in to comment.