Skip to content

Commit

Permalink
Update for release v21.09.1 (#38)
Browse files Browse the repository at this point in the history
* Updated the defaults in `common.pkvars.hcl` to use hardware version 19, which provides the best performance and latest features available in ESXi 7.0 U2.
* Updated the Rocky Linux build to use UEFI; however without secure boot.
* Refactored all builds to pass the language, keyboard, and timezone to the configuration files.
* Refactored all builds with input variable definitions separated into `variables.pkr.hcl`.
* Refactored all builds to use `<build>.auto.pkvars.hcl` for input variables the and `<build>.pkr.hcl` for the template configurations, with simplified names for `<build>`.
* Refactored all builds to use `${path.cwd}/output/` as the path for the manifest post-processor.
  • Loading branch information
tenthirtyam committed Sep 16, 2021
1 parent a159812 commit a982647
Show file tree
Hide file tree
Showing 60 changed files with 2,837 additions and 2,564 deletions.
20 changes: 16 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

![Rainpole](icon.png)

## Release: `21.09`
## Release: `v21.09.1`
September 16, 2021
* Refactored issue templates to use GitHub custom issue forms.
* Refactored all builds to pass the language, keyboard, and timezone to the configuration files.
* Updated the Rocky Linux build to use UEFI; however without secure boot.
* Updated the defaults in `common.pkvars.hcl` to use hardware version 19, which provides the best performance and latest features available in ESXi 7.0 U2. Refer to the VMware vSphere 7.0 [product documentation](https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vm_admin.doc/GUID-789C3913-1053-4850-A0F0-E29C3D32B6DA.html) if using a previous release
* Refactored all builds with input variable definitions separated into `variables.pkr.hcl`.
* Refactored all builds to use `<build>.auto.pkvars.hcl` for input variables the and `<build>.pkr.hcl` for the template configurations, with simplified names for `<build>`.
* Refactored all builds to use `${path.cwd}/output/` as the path for the manifest post-processor.
* Added disclaimers and updated descriptions in script files.
* Updated README.md.

## Release: `v21.09`
September 7, 2021
* Added support for Microsoft Windows Server 2022 machine image builds.
* Refactored configuration files to be generated using templates. Reduces the number of files and passes variables into the `.pkrtpl.hcl` content.
Expand All @@ -15,7 +27,7 @@ September 7, 2021
* Updated CONTRIBUTING.md.
* Updated README.md.

## Release: `21.08`
## Release: `v21.08`
August 18, 2021
* Moved `vsphere.pkrvars.hcl` and `rhsm.pkrvars.hcl` to the `builds` directory.
* Isolated variables to simplify updates to common settings with `builds/common.pkrvars.hcl`.
Expand All @@ -40,7 +52,7 @@ August 18, 2021
* Added MAINTAINERS.md.
* Updated README.md.

## Release: `21.07`
## Release: `v21.07`
July 21, 2021
* Added support for [VMware Photon OS](https://vmware.github.io/photon/) 4.
* Added [support](https://github.com/rainpole/packer-vsphere/issues/18) for [AlmaLinux](http:https://almalinux.org) 8.
Expand All @@ -50,6 +62,6 @@ July 21, 2021
* Added the Packer block to all builds with `required_versions >= "1.7.3"` for Packer.
* Added the Packer block for Windows builds with `required_plugins` and `version = "0.12.0"` for the [Windows-Update plugin](https://github.com/rgl/packer-plugin-windows-update).

## Release: `20.11`
## Release: `v20.11`
November 26, 2020
* Initial release.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ The directory structure of the repository.
│ ├── linux
│ │ └── distribution-version
│ │ ├── *.pkr.hcl
│ │ ├── variables.auto.pkrvars.hcl
│ │ ├── *.auto.pkrvars.hcl
│ │ └── http
│ │ └── ks.pkrtpl.hcl
│ └── windows
│ └── version
│ ├── *.pkr.hcl
│ ├── variables.auto.pkrvars.hcl
│ ├── *.auto.pkrvars.hcl
│ └── cd
│ └── autounattend.pkrtpl.hcl
├── certificates
Expand Down Expand Up @@ -292,7 +292,7 @@ These variables are **only** used if you are performing a Red Hat Enterprise Lin

#### **Machine Image Variables**

Edit the `variables.auto.pkvars.hcl` file in each `builds/<type>/<build>` folder to configure the following virtual machine hardware settings, as required:
Edit the `*.auto.pkvars.hcl` file in each `builds/<type>/<build>` folder to configure the following virtual machine hardware settings, as required:

* CPU Sockets `(init)`
* CPU Cores `(init)`
Expand All @@ -305,7 +305,7 @@ Edit the `variables.auto.pkvars.hcl` file in each `builds/<type>/<build>` folder
#### **Using Environmental Variables**

Some of the variables may include sensitive information and environmental data that you would prefer not to save to clear text files. You can save use environmental variables before running a build using the example below:
Some of the variables may include sensitive information and environmental data that you would prefer not to save to clear text files. You can add there to environmental variables using the example below:

```
export PKR_VAR_vsphere_endpoint="<vsphere_endpoint_fqdn>"
Expand Down Expand Up @@ -485,4 +485,4 @@ Happy building!!!
[vsphere-content-library]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vm_admin.doc/GUID-254B2CE8-20A8-43F0-90E8-3F6776C2C896.html
[vsphere-guestosid]: https://vdc-download.vmware.com/vmwb-repository/dcr-public/b50dcbbf-051d-4204-a3e7-e1b618c1e384/538cf2ec-b34f-4bae-a332-3820ef9e7773/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html
[vsphere-efi]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.security.doc/GUID-898217D4-689D-4EB5-866C-888353FE241C.html
[vsphere-upload]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.storage.doc/GUID-58D77EA5-50D9-4A8E-A15A-D7B3ABA11B87.html?hWord=N4IghgNiBcIK4AcIHswBMAEAzAlhApgM4gC+QA
[vsphere-upload]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.storage.doc/GUID-58D77EA5-50D9-4A8E-A15A-D7B3ABA11B87.html?hWord=N4IghgNiBcIK4AcIHswBMAEAzAlhApgM4gC+QA
2 changes: 1 addition & 1 deletion builds/common.pkrvars.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

// Virtual Machine Settings
common_vm_version = 18
common_vm_version = 19
common_tools_upgrade_policy = true
common_remove_cdrom = true

Expand Down
6 changes: 3 additions & 3 deletions builds/linux/almalinux-8/http/ks.pkrtpl.hcl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# AlmaLinux 8
install
eula --agreed
lang en_US
keyboard us
timezone UTC
lang ${vm_guest_os_language}
keyboard ${vm_guest_os_keyboard}
timezone ${vm_guest_os_timezone}
rootpw --lock
user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel
cdrom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
*/

// Guest Operating System Metadata
vm_guest_os_family = "linux"
vm_guest_os_vendor = "almalinux"
vm_guest_os_member = "server"
vm_guest_os_version = "8"
vm_guest_os_language = "en_US"
vm_guest_os_keyboard = "us"
vm_guest_os_timezone = "UTC"
vm_guest_os_family = "linux"
vm_guest_os_vendor = "almalinux"
vm_guest_os_member = "server"
vm_guest_os_version = "8"

// Virtual Machine Guest Operating System Setting
vm_guest_os_type = "centos8_64Guest"
Expand All @@ -30,8 +33,8 @@ iso_file = "iso-linux-almalinux-8.iso"
iso_checksum = "44f56b309fa0cccf41f4d8a5ca3c9b91bb7da510ff8d8faf93fadef9262df872cb824aa7499c5ada5a7ae743be6b38261ed458c465d84e2504e38ca6f05107d7"

// Boot Settings
vm_boot_order = "disk,cdrom"
vm_boot_wait = "2s"
vm_boot_order = "disk,cdrom"
vm_boot_wait = "2s"

// Communicator Settings
communicator_port = 22
Expand Down
126 changes: 126 additions & 0 deletions builds/linux/almalinux-8/linux-almalinux.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
DESCRIPTION:
AlmaLinux 8 template using the Packer Builder for VMware vSphere (vsphere-iso).
*/

// BLOCK: packer
// The Packer configuration.

packer {
required_version = ">= 1.7.4"
required_plugins {
vsphere = {
version = ">= v1.0.1"
source = "github.com/hashicorp/vsphere"
}
}
}

// BLOCK: locals
// Defines the local variables.

locals {
buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp())
}

// BLOCK: source
// Defines the builder configuration blocks.

source "vsphere-iso" "linux-almalinux" {

// vCenter Server Endpoint Settings and Credentials
vcenter_server = var.vsphere_endpoint
username = var.vsphere_username
password = var.vsphere_password
insecure_connection = var.vsphere_insecure_connection

// vSphere Settings
datacenter = var.vsphere_datacenter
cluster = var.vsphere_cluster
datastore = var.vsphere_datastore
folder = var.vsphere_folder

// Virtual Machine Settings
guest_os_type = var.vm_guest_os_type
vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}"
firmware = var.vm_firmware
CPUs = var.vm_cpu_sockets
cpu_cores = var.vm_cpu_cores
CPU_hot_plug = var.vm_cpu_hot_add
RAM = var.vm_mem_size
RAM_hot_plug = var.vm_mem_hot_add
cdrom_type = var.vm_cdrom_type
disk_controller_type = var.vm_disk_controller_type
storage {
disk_size = var.vm_disk_size
disk_thin_provisioned = var.vm_disk_thin_provisioned
}
network_adapters {
network = var.vsphere_network
network_card = var.vm_network_card
}
vm_version = var.common_vm_version
remove_cdrom = var.common_remove_cdrom
tools_upgrade_policy = var.common_tools_upgrade_policy
notes = "Built by HashiCorp Packer on ${local.buildtime}."

// Removable Media Settings
iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"]
iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}"

// Boot and Provisioning Settings
http_port_min = var.common_http_port_min
http_port_max = var.common_http_port_max
http_content = {
"/ks.cfg" = templatefile("${path.cwd}/http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted, vm_guest_os_language = var.vm_guest_os_language, vm_guest_os_keyboard = var.vm_guest_os_keyboard, vm_guest_os_timezone = var.vm_guest_os_timezone })
}
boot_order = var.vm_boot_order
boot_wait = var.vm_boot_wait
boot_command = ["up", "e", "<down><down><end><wait>", "text ks=http:https://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "<enter><wait><leftCtrlOn>x<leftCtrlOff>"]
ip_wait_timeout = var.common_ip_wait_timeout
shutdown_command = "echo '${var.build_password}' | sudo -S -E shutdown -P now"
shutdown_timeout = var.common_shutdown_timeout

// Communicator Settings and Credentials
communicator = "ssh"
ssh_username = var.build_username
ssh_password = var.build_password
ssh_port = var.communicator_port
ssh_timeout = var.communicator_timeout

// Template and Content Library Settings
convert_to_template = var.common_template_conversion
content_library_destination {
library = var.common_content_library_name
ovf = var.common_content_library_ovf
destroy = var.common_content_library_destroy
}
}

// BLOCK: build
// Defines the builders to run, provisioners, and post-processors.

build {
sources = ["source.vsphere-iso.linux-almalinux"]

provisioner "file" {
destination = "/tmp/root-ca.crt"
source = "../../../certificates/root-ca.crt"
}

provisioner "shell" {
execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'"
environment_vars = [
"BUILD_USERNAME=${var.build_username}",
"BUILD_KEY=${var.build_key}",
"ANSIBLE_USERNAME=${var.ansible_username}",
"ANSIBLE_KEY=${var.ansible_key}"
]
scripts = var.scripts
}

post-processor "manifest" {
output = "${path.cwd}/output/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json"
strip_path = false
}
}
Empty file.

0 comments on commit a982647

Please sign in to comment.