From c441d6de47ff6df8bd5f8236edea710e4b08435d Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Sun, 3 Oct 2021 10:39:44 -0400 Subject: [PATCH] Refactor iso - Uses vendor / distributor `.iso` file name and checksum. - Adds/updates build variables to include `iso_path`, `iso_file`, `iso_checksum_type`, and `iso_checksum_value`. - Updates code style for the variables passed to a templatefile. - Replaces the term "redhat-variant" with "redhat-derivative". - Adds ansible to Ubuntu 20.04 and 18.06 #54 --- README.md | 126 ++++++++++-------- build.sh | 2 +- builds/common.pkrvars.hcl.example | 4 +- .../linux-almalinux.auto.pkrvars.hcl | 8 +- .../linux/almalinux-8/linux-almalinux.pkr.hcl | 32 +++-- builds/linux/almalinux-8/variables.pkr.hcl | 20 +-- .../linux-centos-linux.auto.pkrvars.hcl | 8 +- .../centos-linux-8/linux-centos-linux.pkr.hcl | 34 +++-- builds/linux/centos-linux-8/variables.pkr.hcl | 20 +-- .../linux-centos-stream.auto.pkrvars.hcl | 8 +- .../linux-centos-stream.pkr.hcl | 34 +++-- .../linux/centos-stream-8/variables.pkr.hcl | 20 +-- builds/linux/photon-4/data/ks.pkrtpl.hcl | 2 +- .../photon-4/linux-photon.auto.pkrvars.hcl | 6 +- builds/linux/photon-4/linux-photon.pkr.hcl | 23 ++-- builds/linux/photon-4/variables.pkr.hcl | 22 +-- .../linux-redhat-linux.auto.pkrvars.hcl | 6 +- .../redhat-linux-8/linux-redhat-linux.pkr.hcl | 34 +++-- builds/linux/redhat-linux-8/variables.pkr.hcl | 22 +-- .../linux-rocky-linux.auto.pkrvars.hcl | 8 +- .../rocky-linux-8/linux-rocky-linux.pkr.hcl | 34 +++-- builds/linux/rocky-linux-8/variables.pkr.hcl | 20 +-- .../data/ks.pkrtpl.hcl | 2 +- .../linux-ubuntu-server.auto.pkrvars.hcl | 6 +- .../linux-ubuntu-server.pkr.hcl | 30 +++-- .../ubuntu-server-18-04-lts/variables.pkr.hcl | 20 +-- .../data/user-data.pkrtpl.hcl | 18 ++- .../linux-ubuntu-server.auto.pkrvars.hcl | 6 +- .../linux-ubuntu-server.pkr.hcl | 35 +++-- .../ubuntu-server-20-04-lts/variables.pkr.hcl | 20 +-- builds/windows/windows-10/variables.pkr.hcl | 24 ++-- .../windows-10/windows.auto.pkrvars.hcl | 6 +- builds/windows/windows-10/windows.pkr.hcl | 25 ++-- .../windows-server-2016/variables.pkr.hcl | 32 ++--- .../windows-server.auto.pkrvars.hcl | 8 +- .../windows-server.pkr.hcl | 58 ++++++-- .../windows-server-2019/variables.pkr.hcl | 26 ++-- .../windows-server.auto.pkrvars.hcl | 8 +- .../windows-server.pkr.hcl | 58 ++++++-- .../windows-server-2022/variables.pkr.hcl | 26 ++-- .../windows-server.auto.pkrvars.hcl | 8 +- .../windows-server.pkr.hcl | 58 ++++++-- ...redhat-variant.sh => redhat-derivative.sh} | 0 43 files changed, 588 insertions(+), 379 deletions(-) rename scripts/linux/{redhat-variant.sh => redhat-derivative.sh} (100%) diff --git a/README.md b/README.md index 44e9d5f3d..0b1bc9565 100644 --- a/README.md +++ b/README.md @@ -128,49 +128,50 @@ The files are distributed in the following directories. * **`certificates`** - contains the Trusted Root Authority certificates. * **`manifests`** - manifests created after the completion of each build. -### Step 2 - Prepare the Guest Operating Systems ISOs +### Step 2 - Download the Guest Operating Systems ISOs 1. Download the x64 guest operating system [.iso][iso] images. **Linux Distributions** * VMware Photon OS 4 Server - * [Download][download-linux-photon-server-4] the latest release of the **FULL** `.iso` image. + * [Download][download-linux-photon-server-4] the latest release of the **FULL** `.iso` image. (_e.g._ `photon-4.0-ca7c9e933.iso`) * Ubuntu Server 20.04 LTS - * [Download][download-linux-ubuntu-server-20-04-lts] the latest **LIVE** release `.iso` image. + * [Download][download-linux-ubuntu-server-20-04-lts] the latest **LIVE** release `.iso` image. (_e.g._ `ubuntu-20.04.2-live-server-amd64.iso`) * Ubuntu Server 18.04 LTS - * [Download][download-linux-ubuntu-server-18-04-lts] the latest legacy **NON-LIVE** release` .iso` image. + * [Download][download-linux-ubuntu-server-18-04-lts] the latest legacy **NON-LIVE** release `.iso` image. (_e.g._ `ubuntu-18.04.6-server-amd64.iso`) * Red Hat Enterprise Linux 8 Server - * [Download][download-linux-redhat-server-8] the latest release of the **FULL** (e.g. `RHEL-8-x86_64-dvd1.iso`) `.iso` image. + * [Download][download-linux-redhat-server-8] the latest release of the **FULL** `.iso` image. (_e.g._ `RHEL-8-x86_64-dvd1.iso`) * AlmaLinux 8 Server - * [Download][download-linux-almalinux-server-8] the latest release of the **FULL** (e.g. `AlmaLinux-8-x86_64-dvd1.iso`) `.iso` image. + * [Download][download-linux-almalinux-server-8] the latest release of the **FULL** `.iso` image. (_e.g._ `AlmaLinux-8-x86_64-dvd1.iso`) * Rocky Linux 8 Server - * [Download][download-linux-rocky-server-8] the latest release of the **FULL** (e.g. `Rocky-8-x86_64-dvd1.iso`) `.iso` image. + * [Download][download-linux-rocky-server-8] the latest release of the **FULL** `.iso` image. (_e.g._ `Rocky-8-x86_64-dvd1.iso`) * CentOS Stream 8 Server - * [Download][download-linux-centos-stream-8] the latest release of the **FULL** (e.g. `CentOS-Stream-8-x86_64-dvd1.iso`) `.iso` image. + * [Download][download-linux-centos-stream-8] the latest release of the **FULL** `.iso` image. (_e.g._ `CentOS-Stream-8-x86_64-dvd1.iso`) * CentOS Linux 8 Server - * [Download][download-linux-centos-server-8] the latest release of the **FULL** (e.g. `CentOS-8-x86_64-dvd1.iso`) `.iso` image. + * [Download][download-linux-centos-server-8] the latest release of the **FULL** `.iso` image. (_e.g._ `CentOS-8-x86_64-dvd1.iso`) **Microsoft Windows** * Microsoft Windows Server 2022 * Microsoft Windows Server 2019 * Microsoft Windows Server 2016 - * Microsoft Windows 10 + * Microsoft Windows 10 Professional -2. Rename your guest operating system `.iso` images. The examples in this repository _generally_ use the format of `iso-family-vendor-type-version.iso`. +3. Obtain the checksum type (_e.g._ `sha256`, `md5`, etc.) and checksum value for each guest operating system `.iso` image. This will be use in the build input variables. - Example: `iso-linux-ubuntu-server-20-04-lts.iso` +4. [Upload][vsphere-upload] your guest operating system `.iso` images to the ISO datastore and paths that will be used in your variables. -3. Obtain the SHA-512 checksum for each guest operating system `.iso` image. This will be use in the build input variables. - - Example: - - * macOS terminal: `shasum -a 512 [filename.iso]` - * Linux shell: `sha512sum [filename.iso]` - * Windows command: `certutil -hashfile [filename.iso] sha512` - -4. [Upload][vsphere-upload] your guest operating system `.iso` images to the datastore and path defined in your common variables. + Example: `builds///*.auto.pkvars.hcl` + ``` + common_iso_datastore = "sfo-w01-cl01-ds-nfs01" + ``` - Example: `[sfo-w01-ds-nfs01] /iso`. + Example: `config/common.pkvars.hcl` + ``` + iso_path = "iso/linux/photon" + iso_file = "photon-4.0-ca7c9e933.iso" + iso_checksum_type = "md5" + iso_checksum_value = "d8c4bc561e68afaf7815518f78a5b4ab" + ``` ### Step 3 - Configure the Variables @@ -204,11 +205,11 @@ For example, this is useful for the purposes of running machine image builds for #### **Build Variables** -Edit the `/config/build.pkvars.hcl` file to configure the following: +Edit the `config/build.pkvars.hcl` file to configure the following: * Credentials for the default account on machine images. -Example: `/config/build.pkvars.hcl` +Example: `config/build.pkvars.hcl` ``` build_username = "rainpole" @@ -216,6 +217,13 @@ build_password = "" build_password_encrypted = "" build_key = "" ``` +You can also override the `build_key` value with contents of a file, if required. + +For example: + +``` +build_key = file("${path.root}/config/ssh/build_id_ecdsa.pub") +``` Generate a SHA-512 encrypted password for the _`build_password_encrypted`_ using various other tools like OpenSSL, mkpasswd, etc. @@ -250,19 +258,18 @@ Your identification has been saved in /Users/rainpole/.ssh/id_ecdsa. Your public key has been saved in /Users/rainpole/.ssh/id_ecdsa.pub. ``` -The content of the public key, `build_key`, is added the key to the `.ssh/authorized_keys` file of the `build_username` on the guest operating system. - +The content of the public key, `build_key`, is added the key to the `.ssh/authorized_keys` file of the `build_username` on the guest operating system. >**WARNING**: Replace the default public keys and passwords. ->By default, both Public Key Authentication and Password Authentication are enabled for Linux distributions. If you wish to disable Password Authentication and only use Public Key Authentication, comment or remove the portion of the associated script in the `/scripts` directory. +>By default, both Public Key Authentication and Password Authentication are enabled for Linux distributions. If you wish to disable Password Authentication and only use Public Key Authentication, comment or remove the portion of the associated script in the `scripts` directory. #### **Ansible Variables** -Edit the `/config/ansible.pkvars.hcl` file to configure the following: +Edit the `config/ansible.pkvars.hcl` file to configure the following: * Credentials for the Ansible account on Linux machine images. -Example: `/config/ansible.pkvars.hcl` +Example: `config/ansible.pkvars.hcl` ``` ansible_username = "ansible" @@ -270,16 +277,24 @@ ansible_key = "" ``` >**NOTE**: A random password is generated for the Ansible user. +You can also override the `ansible_key` value with contents of a file, if required. + +For example: + +``` +build_key = file("${path.root}/config/ssh/ansible_id_ecdsa.pub") +``` + #### **Common Variables** -Edit the `/config/common.pkvars.hcl` file to configure the following common variables: +Edit the `config/common.pkvars.hcl` file to configure the following common variables: * Virtual Machine Settings * Template and Content Library Settings * Removable Media Settings * Boot and Provisioning Settings -Example: `/config/common.pkvars.hcl` +Example: `config/common.pkvars.hcl` ``` // Virtual Machine Settings @@ -295,8 +310,6 @@ common_content_library_destroy = true // Removable Media Settings common_iso_datastore = "sfo-w01-cl01-ds-nfs01" -common_iso_path = "iso" -common_iso_hash = "sha512" // Boot and Provisioning Settings common_data_source = "http" @@ -323,12 +336,12 @@ common_http_ip = "172.16.11.254" #### **Proxy Variables** -Edit the `/config/proxy.pkvars.hcl` file to configure the following: +Edit the `config/proxy.pkvars.hcl` file to configure the following: * SOCKS proxy settings used for connecting to Linux machine images. * Credentials for the proxy server (Optional). -Example: `/config/proxy.pkvars.hcl` +Example: `config/proxy.pkvars.hcl` ``` communicator_proxy_host = "proxy.rainpole.io" @@ -338,29 +351,27 @@ communicator_proxy_password = "" ``` #### **Red Hat Subscription Manager Variables** -Edit the `/config/redhat.pkvars.hcl` file to configure the following: +Edit the `config/redhat.pkvars.hcl` file to configure the following: * Credentials for your Red Hat Subscription Manager account. -Example: `/config/redhat.pkvars.hcl` +Example: `config/redhat.pkvars.hcl` ``` rhsm_username = "rainpole" rhsm_password = "" ``` -These variables are **only** used if you are performing a Red Hat Enterprise Linux Server build to register the image with Red Hat Subscription Manager and run a `sudo yum update -y` within the shell provisioner. Before the build completes, the machine image is unregistered from Red Hat Subscription Manager. - - +These variables are **only** used if you are performing a Red Hat Enterprise Linux Server build to register the image with Red Hat Subscription Manager and run a `sudo dnf update -y` within the shell provisioner. Before the build completes, the machine image is unregistered from Red Hat Subscription Manager. #### **vSphere Variables** -Edit the `/buils/vsphere.pkvars.hcl` file to configure the following: +Edit the `builds/vsphere.pkvars.hcl` file to configure the following: * vSphere Endpoint and Credentials * vSphere Settings -Example: `/config/vsphere.pkvars.hcl` +Example: `config/vsphere.pkvars.hcl` ``` vsphere_endpoint = "sfo-w01-vc01.sfo.rainpole.io" @@ -382,14 +393,16 @@ Edit the `*.auto.pkvars.hcl` file in each `builds//` folder to conf * CPU Cores `(init)` * Memory in MB `(init)` * Primary Disk in MB `(init)` -* .iso Image File `(string)` -* .iso Image SHA-512 Checksum `(string)` +* .iso Path `(string)` +* .iso File `(string)` +* .iso Checksum Type `(string)` +* .iso Checksum Value `(string)` - >**Note**: All `variables.auto.pkvars.hcl` default to using the the recommended firmware for the guest operating system, the [VMware Paravirtual SCSI controller][vmware-pvscsi] and the [VMXNET 3][vmware-vmxnet3] network card device types. + >**Note**: All `variables.auto.pkvars.hcl` default to using the [VMware Paravirtual SCSI controller][vmware-pvscsi] and the [VMXNET 3][vmware-vmxnet3] network card device types. #### **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 add there to environmental variables 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 these to environmental variables using the example below: ``` export PKR_VAR_ansible_username="" @@ -412,8 +425,8 @@ export PKR_VAR_vsphere_cluster="" export PKR_VAR_vsphere_datastore=">" export PKR_VAR_vsphere_network="" export PKR_VAR_vsphere_folder="" - ``` + ## Step 4 - Modify the Configurations and Scripts If required, modify the configuration and scripts files, for the Linux distributions and Microsoft Windows. @@ -422,8 +435,6 @@ If required, modify the configuration and scripts files, for the Linux distribut Username and password variables are passed into the kickstart or cloud-init files for each Linux distribution as Packer template files (`.pkrtpl.hcl`) to generate these on-demand. -A SHA-512 encrypted password for the `root` account and the _`build_username`_ (e.g. `rainpole`). It also adds the _`build_username`_ to the sudoers. - ### Microsoft Windows Unattended amd Scripts Variables are passed into the [Microsoft Windows][microsoft-windows-unattend] unattend files (`autounattend.xml`) as Packer template files (`autounattend.pkrtpl.hcl`) to generate these on-demand. @@ -537,23 +548,20 @@ Happy building!!! [//]: Links -[chocolatey]: https://chocolatey.org/why-chocolatey [cloud-init]: https://cloudinit.readthedocs.io/en/latest/ [credits-maher-alasfar-twitter]: https://twitter.com/vmwarelab [credits-maher-alasfar-github]: https://github.com/vmwarelab/cloud-init-scripts [credits-owen-reynolds-twitter]: https://twitter.com/OVDamn [credits-owen-reynolds-github]: https://github.com/getvpro/Build-Packer/blob/master/Scripts/Install-VMTools.ps1 [download-git]: https://git-scm.com/downloads +[download-linux-almalinux-server-8]: https://mirrors.almalinux.org/isos.html +[download-linux-centos-server-8]: http://isoredirect.centos.org/centos/8/isos/x86_64/ +[download-linux-centos-stream-8]: http://isoredirect.centos.org/centos/8-stream/isos/x86_64/ [download-linux-photon-server-4]: https://packages.vmware.com/photon/4.0/ -[download-linux-ubuntu-server-20-04-lts]: https://releases.ubuntu.com/20.04.1/ -[download-linux-ubuntu-server-18-04-lts]: http://cdimage.ubuntu.com/ubuntu/releases/18.04.5/release/ [download-linux-redhat-server-8]: https://access.redhat.com/downloads/content/479/ -[download-linux-redhat-server-7]: https://access.redhat.com/downloads/content/69/ -[download-linux-almalinux-server-8]: https://mirrors.almalinux.org/isos.html [download-linux-rocky-server-8]: https://download.rockylinux.org/pub/rocky/8/isos/x86_64/ -[download-linux-centos-stream-8]: http://isoredirect.centos.org/centos/8-stream/isos/x86_64/ -[download-linux-centos-server-8]: http://isoredirect.centos.org/centos/8/isos/x86_64/ -[download-linux-centos-server-7]: http://isoredirect.centos.org/centos/7/isos/x86_64/ +[download-linux-ubuntu-server-18-04-lts]: http://cdimage.ubuntu.com/ubuntu/releases/18.04.5/release/ +[download-linux-ubuntu-server-20-04-lts]: https://releases.ubuntu.com/20.04.1/ [hashicorp]: https://www.hashicorp.com/ [iso]: https://en.wikipedia.org/wiki/ISO_image [microsoft-kms]: https://docs.microsoft.com/en-us/windows-server/get-started/kmsclientkeys @@ -565,8 +573,8 @@ Happy building!!! [packer-install]: https://www.packer.io/intro/getting-started/install.html [packer-plugin-vsphere]: https://www.packer.io/docs/builders/vsphere/vsphere-iso [packer-plugin-windows-update]: https://github.com/rgl/packer-plugin-windows-update -[packer-variables]: https://www.packer.io/docs/from-1.5/variables#variable-definitions-pkrvars-hcl-files -[photon-kickstart]: https://vmware.github.io/photon/assets/files/html/3.0/photon_user/kickstart.html +[packer-variables]: https://www.packer.io/docs/templates/hcl_templates/variables +[photon-kickstart]: https://vmware.github.io/photon/docs/user-guide/kickstart-through-http/packer-template/ [redhat-kickstart]: https://access.redhat.com/labs/kickstartconfig/ [ssh-keygen]: https://www.ssh.com/ssh/keygen/ [vmware-pvscsi]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.hostclient.doc/GUID-7A595885-3EA5-4F18-A6E7-5952BFC341CC.html diff --git a/build.sh b/build.sh index f5a7a2e0c..9c1b3e86b 100755 --- a/build.sh +++ b/build.sh @@ -573,7 +573,7 @@ info() { echo "License: Apache License Version 2.0." echo "" echo "Versions Used:" - echo "HashiCorp Packer >= 1.7.6." + echo "HashiCorp Packer >= 1.7.6" echo "HashiCorp Packer Plugin for VMware vSphere >= 1.0.1" echo "HashiCorp Packer Plugin for Windows Update >= 0.14.0" echo "" diff --git a/builds/common.pkrvars.hcl.example b/builds/common.pkrvars.hcl.example index a487698bb..5a7dfe95c 100644 --- a/builds/common.pkrvars.hcl.example +++ b/builds/common.pkrvars.hcl.example @@ -17,8 +17,6 @@ common_content_library_destroy = true // Removable Media Settings common_iso_datastore = "sfo-w01-cl01-ds-nfs01" -common_iso_path = "iso" -common_iso_hash = "sha512" // Boot and Provisioning Settings common_data_source = "http" @@ -26,4 +24,4 @@ common_http_ip = null common_http_port_min = 8000 common_http_port_max = 8099 common_ip_wait_timeout = "20m" -common_shutdown_timeout = "15m" +common_shutdown_timeout = "15m" \ No newline at end of file diff --git a/builds/linux/almalinux-8/linux-almalinux.auto.pkrvars.hcl b/builds/linux/almalinux-8/linux-almalinux.auto.pkrvars.hcl index 38a3ef870..73535e796 100644 --- a/builds/linux/almalinux-8/linux-almalinux.auto.pkrvars.hcl +++ b/builds/linux/almalinux-8/linux-almalinux.auto.pkrvars.hcl @@ -29,8 +29,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-linux-almalinux-8.iso" -iso_checksum = "44f56b309fa0cccf41f4d8a5ca3c9b91bb7da510ff8d8faf93fadef9262df872cb824aa7499c5ada5a7ae743be6b38261ed458c465d84e2504e38ca6f05107d7" +iso_path = "iso/linux/rhel-derivative" +iso_file = "AlmaLinux-8.4-x86_64-dvd.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "44f56b309fa0cccf41f4d8a5ca3c9b91bb7da510ff8d8faf93fadef9262df872cb824aa7499c5ada5a7ae743be6b38261ed458c465d84e2504e38ca6f05107d7" // Boot Settings vm_boot_order = "disk,cdrom" @@ -41,5 +43,5 @@ communicator_port = 22 communicator_timeout = "30m" // Provisioner Settings -scripts = ["scripts/linux/redhat-variant.sh"] +scripts = ["scripts/linux/redhat-derivative.sh"] inline = [] \ No newline at end of file diff --git a/builds/linux/almalinux-8/linux-almalinux.pkr.hcl b/builds/linux/almalinux-8/linux-almalinux.pkr.hcl index 903a5efc9..d6c1b56eb 100644 --- a/builds/linux/almalinux-8/linux-almalinux.pkr.hcl +++ b/builds/linux/almalinux-8/linux-almalinux.pkr.hcl @@ -23,7 +23,13 @@ locals { buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) path_manifest = "${path.cwd}/manifests/" data_source_content = { - "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 }) + "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 + }) } data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" : "inst.ks=cdrom:/ks.cfg" } @@ -70,20 +76,24 @@ source "vsphere-iso" "linux-almalinux" { 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}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + http_content = var.common_data_source == "http" ? local.data_source_content : null + cd_content = var.common_data_source == "disk" ? local.data_source_content : null // Boot and Provisioning Settings http_ip = var.common_data_source == "http" ? var.common_http_ip : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null - http_content = var.common_data_source == "http" ? local.data_source_content : null - - cd_content = var.common_data_source == "disk" ? local.data_source_content : null - - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["up", "e", "", "text ${local.data_source_command}", "x"] + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [ + "up", + "e", + "", + "text ${local.data_source_command}", + "x" + ] 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 @@ -134,7 +144,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" strip_path = false } } \ No newline at end of file diff --git a/builds/linux/almalinux-8/variables.pkr.hcl b/builds/linux/almalinux-8/variables.pkr.hcl index 1beae9d39..118f19eb4 100644 --- a/builds/linux/almalinux-8/variables.pkr.hcl +++ b/builds/linux/almalinux-8/variables.pkr.hcl @@ -167,7 +167,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -215,24 +215,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso'/linux/rhel-derivative)" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. 'AlmaLinux--x86_64-dvd.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-linux-almalinux-8.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-almalinux-8.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings @@ -325,7 +325,7 @@ variable "communicator_proxy_username" { variable "communicator_proxy_password" { type = string - description = "The optional password to use to authenticate with the proxy server." + description = "The optional password to authenticate with the proxy server." sensitive = true default = null } diff --git a/builds/linux/centos-linux-8/linux-centos-linux.auto.pkrvars.hcl b/builds/linux/centos-linux-8/linux-centos-linux.auto.pkrvars.hcl index 59f3e80f9..7b2d49d61 100644 --- a/builds/linux/centos-linux-8/linux-centos-linux.auto.pkrvars.hcl +++ b/builds/linux/centos-linux-8/linux-centos-linux.auto.pkrvars.hcl @@ -29,8 +29,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-linux-centos-linux-8.iso" -iso_checksum = "ff1164dc26ba47616f2b26a18158398a7d7930487770a8bb9e573d5758e01255ebc11db68c22976abe684a857083a0fae445e9d41d11a24a2073cdb1b500ae9a" +iso_path = "iso/linux/rhel-derivative" +iso_file = "CentOS-8.4.2105-x86_64-dvd1.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "0394ecfa994db75efc1413207d2e5ac67af4f6685b3b896e2837c682221fd6b2" // Boot Settings vm_boot_order = "disk,cdrom" @@ -41,5 +43,5 @@ communicator_port = 22 communicator_timeout = "30m" // Provisioner Settings -scripts = ["scripts/linux/redhat-variant.sh"] +scripts = ["scripts/linux/redhat-derivative.sh"] inline = [] \ No newline at end of file diff --git a/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl b/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl index 68deb368c..2978f29fa 100644 --- a/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl +++ b/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl @@ -23,7 +23,13 @@ locals { buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) path_manifest = "${path.cwd}/manifests/" data_source_content = { - "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 }) + "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 + }) } data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" : "inst.ks=cdrom:/ks.cfg" } @@ -70,20 +76,24 @@ source "vsphere-iso" "linux-centos-linux" { 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}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + http_content = var.common_data_source == "http" ? local.data_source_content : null + cd_content = var.common_data_source == "disk" ? local.data_source_content : null // Boot and Provisioning Settings http_ip = var.common_data_source == "http" ? var.common_http_ip : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null - http_content = var.common_data_source == "http" ? local.data_source_content : null - - cd_content = var.common_data_source == "disk" ? local.data_source_content : null - - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["up", "e", "", "text ${local.data_source_command}", "x"] + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [ + "up", + "e", + "", + "text ${local.data_source_command}", + "x" + ] 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 @@ -134,7 +144,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" strip_path = false } -} +} \ No newline at end of file diff --git a/builds/linux/centos-linux-8/variables.pkr.hcl b/builds/linux/centos-linux-8/variables.pkr.hcl index 670cf201f..8a7f7a0bb 100644 --- a/builds/linux/centos-linux-8/variables.pkr.hcl +++ b/builds/linux/centos-linux-8/variables.pkr.hcl @@ -167,7 +167,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -215,24 +215,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/linux/rhel-derivative')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. 'CentOS--x86_64-dvd1.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-linux-centos-linux-8.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-centos-linux-8.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings @@ -325,7 +325,7 @@ variable "communicator_proxy_username" { variable "communicator_proxy_password" { type = string - description = "The optional password to use to authenticate with the proxy server." + description = "The optional password to authenticate with the proxy server." sensitive = true default = null } diff --git a/builds/linux/centos-stream-8/linux-centos-stream.auto.pkrvars.hcl b/builds/linux/centos-stream-8/linux-centos-stream.auto.pkrvars.hcl index 1f2d4fec9..6f68527d6 100644 --- a/builds/linux/centos-stream-8/linux-centos-stream.auto.pkrvars.hcl +++ b/builds/linux/centos-stream-8/linux-centos-stream.auto.pkrvars.hcl @@ -29,8 +29,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-linux-centos-stream-8.iso" -iso_checksum = "552cf5dcdc9d3db41791a2b3bbbd18335d75607ca54e7aa8bf28a6ea1d49ce914a55da0bd839123aa96654b7de6db65cc786beb71e6233982ea96ce456a47035" +iso_path = "iso/linux/rhel-derivative" +iso_file = "CentOS-Stream-8-x86_64-latest-dvd1.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "e8803baad68a85e7bf75958762144151b502a6daa4234cdd5142427f55ddb041" // Boot Settings vm_boot_order = "disk,cdrom" @@ -41,5 +43,5 @@ communicator_port = 22 communicator_timeout = "30m" // Provisioner Settings -scripts = ["scripts/linux/redhat-variant.sh"] +scripts = ["scripts/linux/redhat-derivative.sh"] inline = [] \ No newline at end of file diff --git a/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl b/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl index 742c5b74d..13439fb62 100644 --- a/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl +++ b/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl @@ -23,7 +23,13 @@ locals { buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) path_manifest = "${path.cwd}/manifests/" data_source_content = { - "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 }) + "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 + }) } data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" : "inst.ks=cdrom:/ks.cfg" } @@ -70,20 +76,24 @@ source "vsphere-iso" "linux-centos-stream" { 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}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + http_content = var.common_data_source == "http" ? local.data_source_content : null + cd_content = var.common_data_source == "disk" ? local.data_source_content : null // Boot and Provisioning Settings http_ip = var.common_data_source == "http" ? var.common_http_ip : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null - http_content = var.common_data_source == "http" ? local.data_source_content : null - - cd_content = var.common_data_source == "disk" ? local.data_source_content : null - - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["up", "e", "", "text ${local.data_source_command}", "x"] + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [ + "up", + "e", + "", + "text ${local.data_source_command}", + "x" + ] 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 @@ -134,7 +144,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" strip_path = false } -} +} \ No newline at end of file diff --git a/builds/linux/centos-stream-8/variables.pkr.hcl b/builds/linux/centos-stream-8/variables.pkr.hcl index 94a076272..4d22addb2 100644 --- a/builds/linux/centos-stream-8/variables.pkr.hcl +++ b/builds/linux/centos-stream-8/variables.pkr.hcl @@ -167,7 +167,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -215,24 +215,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/linux/rhel-derivative')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. 'CentOS-Stream--x86_64-latest-dvd1.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-linux-centos-stream-8.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-centos-stream-8.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings @@ -325,7 +325,7 @@ variable "communicator_proxy_username" { variable "communicator_proxy_password" { type = string - description = "The optional password to use to authenticate with the proxy server." + description = "The optional password to authenticate with the proxy server." sensitive = true default = null } diff --git a/builds/linux/photon-4/data/ks.pkrtpl.hcl b/builds/linux/photon-4/data/ks.pkrtpl.hcl index 4ef1723a8..45564653d 100644 --- a/builds/linux/photon-4/data/ks.pkrtpl.hcl +++ b/builds/linux/photon-4/data/ks.pkrtpl.hcl @@ -33,4 +33,4 @@ "network": { "type": "dhcp" } -} +} \ No newline at end of file diff --git a/builds/linux/photon-4/linux-photon.auto.pkrvars.hcl b/builds/linux/photon-4/linux-photon.auto.pkrvars.hcl index beaeaf2dd..0ddba12bd 100644 --- a/builds/linux/photon-4/linux-photon.auto.pkrvars.hcl +++ b/builds/linux/photon-4/linux-photon.auto.pkrvars.hcl @@ -26,8 +26,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-linux-photon-4.iso" -iso_checksum = "9cb0ae0329a50733f56e921c1e220ce3e9d328499890b8202e05991daec34c4184ef03606caf706e9058035115c23fef1cacbb184200fca8ec577a191ad3f394" +iso_path = "iso/linux/photon" +iso_file = "photon-4.0-ca7c9e933.iso" +iso_checksum_type = "md5" +iso_checksum_value = "d8c4bc561e68afaf7815518f78a5b4ab" // Boot Settings vm_boot_order = "disk,cdrom" diff --git a/builds/linux/photon-4/linux-photon.pkr.hcl b/builds/linux/photon-4/linux-photon.pkr.hcl index 5acc85989..d61c74f6b 100644 --- a/builds/linux/photon-4/linux-photon.pkr.hcl +++ b/builds/linux/photon-4/linux-photon.pkr.hcl @@ -66,19 +66,22 @@ source "vsphere-iso" "linux-photon" { 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}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + http_content = { + "/ks.json" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { + build_username = var.build_username + build_password_encrypted = var.build_password_encrypted + }) + "/packages.json" = file("${abspath(path.root)}/data/packages_minimal.json") + } // Boot and Provisioning Settings http_ip = var.common_http_ip http_port_min = var.common_http_port_min http_port_max = var.common_http_port_max - http_content = { - "/ks.json" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted }) - "/packages.json" = file("${abspath(path.root)}/data/packages_minimal.json") - } - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait boot_command = [ "c", "linux /isolinux/vmlinuz root=/dev/ram0 loglevel=3 insecure_installation=1 ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.json photon.media=cdrom", @@ -137,7 +140,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" strip_path = false } -} +} \ No newline at end of file diff --git a/builds/linux/photon-4/variables.pkr.hcl b/builds/linux/photon-4/variables.pkr.hcl index 596128a94..bd5e16bd6 100644 --- a/builds/linux/photon-4/variables.pkr.hcl +++ b/builds/linux/photon-4/variables.pkr.hcl @@ -149,7 +149,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -186,7 +186,7 @@ variable "common_content_library_ovf" { variable "common_content_library_destroy" { type = bool - description = "Delete the virtual machine afer exporting to the content library." + description = "Delete the virtual machine after exporting to the content library." default = true } @@ -197,24 +197,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/linux/photon')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. 'photon-.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-linux-photon-4.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'md5')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-photon-4.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings @@ -307,7 +307,7 @@ variable "communicator_proxy_username" { variable "communicator_proxy_password" { type = string - description = "The optional password to use to authenticate with the proxy server." + description = "The optional password to authenticate with the proxy server." sensitive = true default = null } diff --git a/builds/linux/redhat-linux-8/linux-redhat-linux.auto.pkrvars.hcl b/builds/linux/redhat-linux-8/linux-redhat-linux.auto.pkrvars.hcl index 073a86937..a15c225f0 100644 --- a/builds/linux/redhat-linux-8/linux-redhat-linux.auto.pkrvars.hcl +++ b/builds/linux/redhat-linux-8/linux-redhat-linux.auto.pkrvars.hcl @@ -29,8 +29,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-linux-redhat-linux-8.iso" -iso_checksum = "3b3f4ad5a0b8ef289643bf8cb7f6f5a0fa7b2cbca747dc0ed6b588f574f38bee8c741b76519b8d0bf7dd4328d9ecc950bad443c22ddc8347837a4c58cd85b3a7" +iso_path = "iso/linux/rhel" +iso_file = "rhel-8.4-x86_64-dvd.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "48f955712454c32718dcde858dea5aca574376a1d7a4b0ed6908ac0b85597811" // Boot Settings vm_boot_order = "disk,cdrom" diff --git a/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl b/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl index 2cae52512..e7add7e99 100644 --- a/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl +++ b/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl @@ -23,7 +23,13 @@ locals { buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) path_manifest = "${path.cwd}/manifests/" data_source_content = { - "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 }) + "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 + }) } data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" : "inst.ks=cdrom:/ks.cfg" } @@ -70,20 +76,24 @@ source "vsphere-iso" "linux-redhat-linux" { 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}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + http_content = var.common_data_source == "http" ? local.data_source_content : null + cd_content = var.common_data_source == "disk" ? local.data_source_content : null // Boot and Provisioning Settings http_ip = var.common_data_source == "http" ? var.common_http_ip : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null - http_content = var.common_data_source == "http" ? local.data_source_content : null - - cd_content = var.common_data_source == "disk" ? local.data_source_content : null - - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["up", "e", "", "text ${local.data_source_command}", "x"] + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [ + "up", + "e", + "", + "text ${local.data_source_command}", + "x" + ] 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 @@ -136,7 +146,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" strip_path = false } -} +} \ No newline at end of file diff --git a/builds/linux/redhat-linux-8/variables.pkr.hcl b/builds/linux/redhat-linux-8/variables.pkr.hcl index e28600c6e..5175a0138 100644 --- a/builds/linux/redhat-linux-8/variables.pkr.hcl +++ b/builds/linux/redhat-linux-8/variables.pkr.hcl @@ -181,7 +181,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -218,7 +218,7 @@ variable "common_content_library_ovf" { variable "common_content_library_destroy" { type = bool - description = "Delete the virtual machine afer exporting to the content library." + description = "Delete the virtual machine after exporting to the content library." default = true } @@ -229,24 +229,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/linux/rhel')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. 'rhel--x86_64-dvd.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-linux-redhat-linux-8.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-redhat-linux-8.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings @@ -339,7 +339,7 @@ variable "communicator_proxy_username" { variable "communicator_proxy_password" { type = string - description = "The optional password to use to authenticate with the proxy server." + description = "The optional password to authenticate with the proxy server." sensitive = true default = null } diff --git a/builds/linux/rocky-linux-8/linux-rocky-linux.auto.pkrvars.hcl b/builds/linux/rocky-linux-8/linux-rocky-linux.auto.pkrvars.hcl index 41e8020f3..58152000c 100644 --- a/builds/linux/rocky-linux-8/linux-rocky-linux.auto.pkrvars.hcl +++ b/builds/linux/rocky-linux-8/linux-rocky-linux.auto.pkrvars.hcl @@ -29,8 +29,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-linux-rocky-linux-8.iso" -iso_checksum = "dbfacdbbfd50059a0dda5c19071bc2f55496f3651279eafa6f50d2ea2d941fdd8b43b8710e2187cdbfe630fa7efb5d3b047ee0cdbc2f8d09bd5f68a7014e0d0c" +iso_path = "iso/linux/rhel-derivative" +iso_file = "Rocky-8.4-x86_64-dvd1.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "ffe2fae67da6702d859cfb0b321561a5d616ce87a963d8a25b018c9c3d52d9a4" // Boot Settings vm_boot_order = "disk,cdrom" @@ -41,5 +43,5 @@ communicator_port = 22 communicator_timeout = "30m" // Provisioner Settings -scripts = ["scripts/linux/redhat-variant.sh"] +scripts = ["scripts/linux/redhat-derivative.sh"] inline = [] \ No newline at end of file diff --git a/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl b/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl index c656b3108..b611e2259 100644 --- a/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl +++ b/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl @@ -23,7 +23,13 @@ locals { buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) path_manifest = "${path.cwd}/manifests/" data_source_content = { - "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 }) + "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 + }) } data_source_command = var.common_data_source == "http" ? "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" : "inst.ks=cdrom:/ks.cfg" } @@ -70,20 +76,24 @@ source "vsphere-iso" "linux-rocky-linux" { 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}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + http_content = var.common_data_source == "http" ? local.data_source_content : null + cd_content = var.common_data_source == "disk" ? local.data_source_content : null // Boot and Provisioning Settings http_ip = var.common_data_source == "http" ? var.common_http_ip : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null - http_content = var.common_data_source == "http" ? local.data_source_content : null - - cd_content = var.common_data_source == "disk" ? local.data_source_content : null - - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["up", "e", "", "text ${local.data_source_command}", "x"] + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [ + "up", + "e", + "", + "text ${local.data_source_command}", + "x" + ] 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 @@ -134,7 +144,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" strip_path = false } -} +} \ No newline at end of file diff --git a/builds/linux/rocky-linux-8/variables.pkr.hcl b/builds/linux/rocky-linux-8/variables.pkr.hcl index 49bc6b6ea..73c7df4c3 100644 --- a/builds/linux/rocky-linux-8/variables.pkr.hcl +++ b/builds/linux/rocky-linux-8/variables.pkr.hcl @@ -167,7 +167,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -204,7 +204,7 @@ variable "common_content_library_ovf" { variable "common_content_library_destroy" { type = bool - description = "Delete the virtual machine afer exporting to the content library." + description = "Delete the virtual machine after exporting to the content library." default = true } @@ -215,24 +215,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/linux/rhel-derivative')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. 'Rocky--x86_64-dvd1.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-rockylinux-8.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-rocky-linux-8.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings diff --git a/builds/linux/ubuntu-server-18-04-lts/data/ks.pkrtpl.hcl b/builds/linux/ubuntu-server-18-04-lts/data/ks.pkrtpl.hcl index 8acb5ba21..e592fd794 100644 --- a/builds/linux/ubuntu-server-18-04-lts/data/ks.pkrtpl.hcl +++ b/builds/linux/ubuntu-server-18-04-lts/data/ks.pkrtpl.hcl @@ -37,7 +37,7 @@ d-i passwd/root-password-crypted password ${build_password_encrypted} # Package Configuration tasksel tasksel/first standard -d-i pkgsel/include string openssh-server open-vm-tools +d-i pkgsel/include string openssh-server open-vm-tools ansible d-i pkgsel/install-language-support boolean false # Disable Automatic Package Updates diff --git a/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.auto.pkrvars.hcl b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.auto.pkrvars.hcl index 1b8153bb4..6b1810d85 100644 --- a/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.auto.pkrvars.hcl +++ b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.auto.pkrvars.hcl @@ -29,8 +29,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-linux-ubuntu-server-18-04-lts.iso" -iso_checksum = "43738d7dfd3e2661e4d55d2e0f9d8150f0687f4335af9b4dac047bf45fafcb4a4831685281fd5a318c5747681c351375d1129094d3f1bf38d88ab4bb49b6c457" +iso_path = "iso/linux/ubuntu" +iso_file = "ubuntu-18.04.6-server-amd64.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "f5cbb8104348f0097a8e513b10173a07dbc6684595e331cb06f93f385d0aecf6" // Boot Settings vm_boot_order = "disk,cdrom" diff --git a/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl index c0fcfe3e5..bf79df471 100644 --- a/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl +++ b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl @@ -66,19 +66,26 @@ source "vsphere-iso" "linux-ubuntu-server" { 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}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + http_content = { + "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 and Provisioning Settings http_ip = var.common_http_ip http_port_min = var.common_http_port_min http_port_max = var.common_http_port_max - http_content = { - "/ks.cfg" = templatefile("${abspath(path.root)}/data/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 = ["", + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [ + "", "", "", "", @@ -91,7 +98,8 @@ source "vsphere-iso" "linux-ubuntu-server" { "/install/vmlinuz initrd=/install/initrd.gz", " priority=critical locale=${var.vm_guest_os_language}", " url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", - ""] + "" + ] 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 @@ -142,7 +150,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}.json" strip_path = false } -} +} \ No newline at end of file diff --git a/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl b/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl index 3b9237d7b..f5550a507 100644 --- a/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl @@ -167,7 +167,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -204,7 +204,7 @@ variable "common_content_library_ovf" { variable "common_content_library_destroy" { type = bool - description = "Delete the virtual machine afer exporting to the content library." + description = "Delete the virtual machine after exporting to the content library." default = true } @@ -215,24 +215,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/linux/ubuntu')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. 'ubuntu--server-amd64.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-linux-ubuntu-server-18-04-lts.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-ubuntu-server-18-04-lts.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings diff --git a/builds/linux/ubuntu-server-20-04-lts/data/user-data.pkrtpl.hcl b/builds/linux/ubuntu-server-20-04-lts/data/user-data.pkrtpl.hcl index 9d40e1b1c..4fb2a2709 100644 --- a/builds/linux/ubuntu-server-20-04-lts/data/user-data.pkrtpl.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/data/user-data.pkrtpl.hcl @@ -2,7 +2,6 @@ autoinstall: version: 1 early-commands: - # Ensures that Packer does not connect too soon. - sudo systemctl stop ssh locale: ${vm_guest_os_language} keyboard: @@ -14,22 +13,21 @@ autoinstall: hostname: ubuntu-server username: ${build_username} password: ${build_password_encrypted} - network: - network: - version: 2 - ethernets: - ens33: - dhcp4: true ssh: install-server: true allow-pw: true + apt: + primary: + - arches: [i386, amd64] + uri: "http://us.archive.ubuntu.com/ubuntu/" packages: - openssh-server - open-vm-tools + - ansible user-data: disable_root: false + timezone: ${vm_guest_os_timezone} late-commands: - - 'sed -i "s/dhcp4: true/&\n dhcp-identifier: mac/" /target/etc/netplan/00-installer-config.yaml' + - sed -i -e 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /target/etc/ssh/sshd_config - echo '${build_username} ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/${build_username} - - curtin in-target --target=/target -- chmod 440 /etc/sudoers.d/${build_username} - timezone: ${vm_guest_os_timezone} \ No newline at end of file + - curtin in-target --target=/target -- chmod 440 /etc/sudoers.d/${build_username} \ No newline at end of file diff --git a/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.auto.pkrvars.hcl b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.auto.pkrvars.hcl index 147e9cc1b..0f3ad94d7 100644 --- a/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.auto.pkrvars.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.auto.pkrvars.hcl @@ -29,8 +29,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-linux-ubuntu-server-20-04-lts.iso" -iso_checksum = "302c990c6d69575ff24c96566e5c7e26bf36908abb0cd546e22687c46fb07bf8dba595bf77a9d4fd9ab63e75c0437c133f35462fd41ea77f6f616140cd0e5e6a" +iso_path = "iso/linux/ubuntu" +iso_file = "ubuntu-20.04.3-live-server-amd64.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98" // Boot Settings vm_boot_order = "disk,cdrom" diff --git a/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl index 2c5160636..c78a1e0d2 100644 --- a/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl @@ -24,7 +24,13 @@ locals { path_manifest = "${path.cwd}/manifests/" data_source_content = { "/meta-data" = file("${abspath(path.root)}/data/meta-data") - "/user-data" = templatefile("${abspath(path.root)}/data/user-data.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 }) + "/user-data" = templatefile("${abspath(path.root)}/data/user-data.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 + }) } data_source_command = var.common_data_source == "http" ? "ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/" : "ds=nocloud" } @@ -71,21 +77,24 @@ source "vsphere-iso" "linux-ubuntu-server" { 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}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + http_content = var.common_data_source == "http" ? local.data_source_content : null + cd_content = var.common_data_source == "disk" ? local.data_source_content : null + cd_label = var.common_data_source == "disk" ? "cidata" : null // Boot and Provisioning Settings http_ip = var.common_data_source == "http" ? var.common_http_ip : null http_port_min = var.common_data_source == "http" ? var.common_http_port_min : null http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null - http_content = var.common_data_source == "http" ? local.data_source_content : null - - cd_label = var.common_data_source == "disk" ? "cidata" : null - cd_content = var.common_data_source == "disk" ? local.data_source_content : null - - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = [" ", "autoinstall ", "ip=dhcp ipv6.disable=1 ${local.data_source_command} ", ""] + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [ + " ", + "autoinstall ", + "${local.data_source_command} ", + "" + ] 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 @@ -136,7 +145,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}.json" strip_path = false } -} +} \ No newline at end of file diff --git a/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl b/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl index fcc364b82..4cf9b9502 100644 --- a/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl @@ -167,7 +167,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -204,7 +204,7 @@ variable "common_content_library_ovf" { variable "common_content_library_destroy" { type = bool - description = "Delete the virtual machine afer exporting to the content library." + description = "Delete the virtual machine after exporting to the content library." default = true } @@ -215,24 +215,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/linux/ubuntu')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. 'ubuntu--live-server-amd64.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-linux-ubuntu-server-20-04-lts.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-ubuntu-server-20-04-lts.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings diff --git a/builds/windows/windows-10/variables.pkr.hcl b/builds/windows/windows-10/variables.pkr.hcl index 18c289b46..d59227b3e 100644 --- a/builds/windows/windows-10/variables.pkr.hcl +++ b/builds/windows/windows-10/variables.pkr.hcl @@ -176,7 +176,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -224,24 +224,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/windows')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. '_windows__business_editions_version__x64_dvd_.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-windows-10.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-10.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings @@ -251,6 +251,12 @@ variable "common_data_source" { description = "The provisioning data source ('http' or 'disk')." } +variable "common_http_ip" { + type = string + description = "Define an IP address on the host to use for the HTTP server." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." diff --git a/builds/windows/windows-10/windows.auto.pkrvars.hcl b/builds/windows/windows-10/windows.auto.pkrvars.hcl index e0f44002b..b58f27d86 100644 --- a/builds/windows/windows-10/windows.auto.pkrvars.hcl +++ b/builds/windows/windows-10/windows.auto.pkrvars.hcl @@ -32,8 +32,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-windows-10.iso" -iso_checksum = "a5a224237d79b605a761e912295a76de84c56ff9130ec99e98138d75c93ad6d2023cd7455eebb36a95462ece813bc5f58a90b319cbffcf0eb65cf7c43dd851cc" +iso_path = "iso/windows" +iso_file = "en-us_windows_10_business_editions_version_21h1_updated_sep_2021_x64_dvd_56628c48.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "852C6A57D1660D2FF0745EBE16DC6CF1AAA67FC7C608C06921082403BACC6285" // Boot Settings vm_boot_order = "disk,cdrom" diff --git a/builds/windows/windows-10/windows.pkr.hcl b/builds/windows/windows-10/windows.pkr.hcl index 75ca01a53..47ba580c7 100644 --- a/builds/windows/windows-10/windows.pkr.hcl +++ b/builds/windows/windows-10/windows.pkr.hcl @@ -26,8 +26,8 @@ packer { // Defines the local variables. locals { - buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) - path_manifest = "${path.cwd}/manifests/" + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) + path_manifest = "${path.cwd}/manifests/" } // BLOCK: source @@ -72,23 +72,20 @@ source "vsphere-iso" "windows-10-professional" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { - os_image = "Windows 10 Pro" - kms_key = "W269N-WFGWX-YVC9B-4J6C9-T83GX" - - build_username = var.build_username - build_password = var.build_password - - vm_inst_os_language = var.vm_inst_os_language - vm_inst_os_keyboard = var.vm_inst_os_keyboard - + os_image = "Windows 10 Pro" + kms_key = "W269N-WFGWX-YVC9B-4J6C9-T83GX" + build_username = var.build_username + build_password = var.build_password + vm_inst_os_language = var.vm_inst_os_language + vm_inst_os_keyboard = var.vm_inst_os_keyboard 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 @@ -166,7 +163,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-professional.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}.json" strip_path = false } } diff --git a/builds/windows/windows-server-2016/variables.pkr.hcl b/builds/windows/windows-server-2016/variables.pkr.hcl index be238363e..d472708d1 100644 --- a/builds/windows/windows-server-2016/variables.pkr.hcl +++ b/builds/windows/windows-server-2016/variables.pkr.hcl @@ -191,7 +191,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -228,7 +228,7 @@ variable "common_content_library_ovf" { variable "common_content_library_destroy" { type = bool - description = "Delete the virtual machine afer exporting to the content library." + description = "Delete the virtual machine after exporting to the content library." default = true } @@ -239,24 +239,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/windows')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. '<_windows_server_.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-windows-server-2016.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha1')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-server-2016.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings @@ -266,6 +266,12 @@ variable "common_data_source" { description = "The provisioning data source ('http' or 'disk')." } +variable "common_http_ip" { + type = string + description = "Define an IP address on the host to use for the HTTP server." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." @@ -276,12 +282,6 @@ variable "common_http_port_max" { description = "The end of the HTTP port range." } -variable "http_file" { - type = string - description = "The guest operating system boot file(s)." - default = "" -} - variable "vm_boot_order" { type = string description = "The boot order for virtual machines devices." diff --git a/builds/windows/windows-server-2016/windows-server.auto.pkrvars.hcl b/builds/windows/windows-server-2016/windows-server.auto.pkrvars.hcl index bfd56a54c..c82aec37f 100644 --- a/builds/windows/windows-server-2016/windows-server.auto.pkrvars.hcl +++ b/builds/windows/windows-server-2016/windows-server.auto.pkrvars.hcl @@ -33,8 +33,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-windows-server-2016.iso" -iso_checksum = "12245fad2f514265732fa3f9a24bc72cfc44ba773f208b2c2eecd75ee4a1709e89a8ba2191b5d58f19cd34d5c8186f9879e58f0e1490a4521a88503767326dd2" +iso_path = "iso/windows" +iso_file = "en_windows_server_2016_x64_dvd_9327751.iso" +iso_checksum_type = "sha1" +iso_checksum_value = "7E33DF150CB4D1FE3503E23433A1867DDD79A6EE" // Boot Settings vm_boot_order = "disk,cdrom" @@ -47,7 +49,7 @@ communicator_port = 5985 communicator_timeout = "12h" // Provisioner Settings -scripts = [ "scripts/windows/windows-server-prepare.ps1" ] +scripts = ["scripts/windows/windows-server-prepare.ps1"] inline = [ "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))", "choco feature enable -n allowGlobalConfirmation", diff --git a/builds/windows/windows-server-2016/windows-server.pkr.hcl b/builds/windows/windows-server-2016/windows-server.pkr.hcl index 5e75113a5..0a2a7bf47 100644 --- a/builds/windows/windows-server-2016/windows-server.pkr.hcl +++ b/builds/windows/windows-server-2016/windows-server.pkr.hcl @@ -72,14 +72,22 @@ source "vsphere-iso" "windows-server-standard-core" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2016 SERVERSTANDARDCORE", kms_key = "WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2016 SERVERSTANDARDCORE" + kms_key = "WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -150,14 +158,22 @@ source "vsphere-iso" "windows-server-standard-dexp" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2016 SERVERSTANDARD", kms_key = "WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2016 SERVERSTANDARD" + kms_key = "WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -229,14 +245,22 @@ source "vsphere-iso" "windows-server-datacenter-core" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2016 SERVERDATACENTERCORE", kms_key = "CB7KF-BWN84-R7R2Y-793K2-8XDDG", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2016 SERVERDATACENTERCORE" + kms_key = "CB7KF-BWN84-R7R2Y-793K2-8XDDG" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -308,14 +332,22 @@ source "vsphere-iso" "windows-server-datacenter-dexp" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2016 SERVERDATACENTER", kms_key = "CB7KF-BWN84-R7R2Y-793K2-8XDDG", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2016 SERVERDATACENTER" + kms_key = "CB7KF-BWN84-R7R2Y-793K2-8XDDG" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -392,7 +424,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_member}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_member}.json" strip_path = false } } \ No newline at end of file diff --git a/builds/windows/windows-server-2019/variables.pkr.hcl b/builds/windows/windows-server-2019/variables.pkr.hcl index 5cd4fd34b..4d6e22a84 100644 --- a/builds/windows/windows-server-2019/variables.pkr.hcl +++ b/builds/windows/windows-server-2019/variables.pkr.hcl @@ -191,7 +191,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -228,7 +228,7 @@ variable "common_content_library_ovf" { variable "common_content_library_destroy" { type = bool - description = "Delete the virtual machine afer exporting to the content library." + description = "Delete the virtual machine after exporting to the content library." default = true } @@ -239,24 +239,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/windows')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. '_windows_server__updated__x64_dvd_.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-windows-server-2019.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-server-2019.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings @@ -266,6 +266,12 @@ variable "common_data_source" { description = "The provisioning data source ('http' or 'disk')." } +variable "common_http_ip" { + type = string + description = "Define an IP address on the host to use for the HTTP server." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." diff --git a/builds/windows/windows-server-2019/windows-server.auto.pkrvars.hcl b/builds/windows/windows-server-2019/windows-server.auto.pkrvars.hcl index fa6a97142..5878911b6 100644 --- a/builds/windows/windows-server-2019/windows-server.auto.pkrvars.hcl +++ b/builds/windows/windows-server-2019/windows-server.auto.pkrvars.hcl @@ -33,8 +33,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-windows-server-2019.iso" -iso_checksum = "1c5e178d0aa403acf756ec2be356059ea833c662406a0bcc4531fce144bfc2c69212cb78bf138ecdbc23e7ed05c7d06603409943a2d93d8917a6bdbd01adc37b" +iso_path = "iso/windows" +iso_file = "en-us_windows_server_2019_updated_aug_2021_x64_dvd_a6431a28.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "0067AFE7FDC4E61F677BD8C35A209082AA917DF9C117527FC4B2B52A447E89BB" // Boot Settings vm_boot_order = "disk,cdrom" @@ -47,7 +49,7 @@ communicator_port = 5985 communicator_timeout = "12h" // Provisioner Settings -scripts = [ "scripts/windows/windows-server-prepare.ps1" ] +scripts = ["scripts/windows/windows-server-prepare.ps1"] inline = [ "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))", "choco feature enable -n allowGlobalConfirmation", diff --git a/builds/windows/windows-server-2019/windows-server.pkr.hcl b/builds/windows/windows-server-2019/windows-server.pkr.hcl index 3469b0384..610c18987 100644 --- a/builds/windows/windows-server-2019/windows-server.pkr.hcl +++ b/builds/windows/windows-server-2019/windows-server.pkr.hcl @@ -72,14 +72,22 @@ source "vsphere-iso" "windows-server-standard-core" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2019 SERVERSTANDARDCORE", kms_key = "N69G4-B89J2-4G8F4-WWYCC-J464C", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2019 SERVERSTANDARDCORE" + kms_key = "N69G4-B89J2-4G8F4-WWYCC-J464C" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -151,14 +159,22 @@ source "vsphere-iso" "windows-server-standard-dexp" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2019 SERVERSTANDARD", kms_key = "N69G4-B89J2-4G8F4-WWYCC-J464C", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2019 SERVERSTANDARD" + kms_key = "N69G4-B89J2-4G8F4-WWYCC-J464C" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -230,14 +246,22 @@ source "vsphere-iso" "windows-server-datacenter-core" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2019 SERVERDATACENTERCORE", kms_key = "WMDGN-G9PQG-XVVXX-R3X43-63DFG", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2019 SERVERDATACENTERCORE" + kms_key = "WMDGN-G9PQG-XVVXX-R3X43-63DFG" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -309,14 +333,22 @@ source "vsphere-iso" "windows-server-datacenter-dexp" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2019 SERVERDATACENTER", kms_key = "WMDGN-G9PQG-XVVXX-R3X43-63DFG", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2019 SERVERDATACENTER" + kms_key = "WMDGN-G9PQG-XVVXX-R3X43-63DFG" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -393,7 +425,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_member}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_member}.json" strip_path = false } } \ No newline at end of file diff --git a/builds/windows/windows-server-2022/variables.pkr.hcl b/builds/windows/windows-server-2022/variables.pkr.hcl index 5c144c0a7..cbe2feb0f 100644 --- a/builds/windows/windows-server-2022/variables.pkr.hcl +++ b/builds/windows/windows-server-2022/variables.pkr.hcl @@ -191,7 +191,7 @@ variable "vm_network_card" { variable "common_vm_version" { type = number - description = "The vSphere virtual hardware version. (e.g. '18')" + description = "The vSphere virtual hardware version. (e.g. '19')" } variable "common_tools_upgrade_policy" { @@ -228,7 +228,7 @@ variable "common_content_library_ovf" { variable "common_content_library_destroy" { type = bool - description = "Delete the virtual machine afer exporting to the content library." + description = "Delete the virtual machine after exporting to the content library." default = true } @@ -239,24 +239,24 @@ variable "common_iso_datastore" { description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" } -variable "common_iso_path" { +variable "iso_path" { type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" + description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/windows')" } -variable "common_iso_hash" { +variable "iso_file" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" + description = "The file name of the ISO image used by the vendor. (e.g. '_windows_server_version__updated__x64_dvd_.iso')" } -variable "iso_file" { +variable "iso_checksum_type" { type = string - description = "The file name of the ISO image. (e.g. 'iso-windows-server-2019.iso')" + description = "The checksum algorithm used by the vendor. (e.g. 'sha256')" } -variable "iso_checksum" { +variable "iso_checksum_value" { type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-server-2019.iso')" + description = "The checksum value provided by the vendor." } // Boot Settings @@ -266,6 +266,12 @@ variable "common_data_source" { description = "The provisioning data source ('http' or 'disk')." } +variable "common_http_ip" { + type = string + description = "Define an IP address on the host to use for the HTTP server." + default = null +} + variable "common_http_port_min" { type = number description = "The start of the HTTP port range." diff --git a/builds/windows/windows-server-2022/windows-server.auto.pkrvars.hcl b/builds/windows/windows-server-2022/windows-server.auto.pkrvars.hcl index 11748621b..1dcce01dd 100644 --- a/builds/windows/windows-server-2022/windows-server.auto.pkrvars.hcl +++ b/builds/windows/windows-server-2022/windows-server.auto.pkrvars.hcl @@ -33,8 +33,10 @@ vm_disk_thin_provisioned = true vm_network_card = "vmxnet3" // Removable Media Settings -iso_file = "iso-windows-server-2022.iso" -iso_checksum = "1c5e178d0aa403acf756ec2be356059ea833c662406a0bcc4531fce144bfc2c69212cb78bf138ecdbc23e7ed05c7d06603409943a2d93d8917a6bdbd01adc37b" +iso_path = "iso/windows" +iso_file = "en-us_windows_server_version_2022_updated_sep_2021_x64_dvd_ae6b4843.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "DC6877B430A559DBC3440C65F4B5B1C685E71B4B19934AC049C8ED0E00206CD0" // Boot Settings vm_boot_order = "disk,cdrom" @@ -47,7 +49,7 @@ communicator_port = 5985 communicator_timeout = "12h" // Provisioner Settings -scripts = [ "scripts/windows/windows-server-prepare.ps1" ] +scripts = ["scripts/windows/windows-server-prepare.ps1"] inline = [ "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))", "choco feature enable -n allowGlobalConfirmation", diff --git a/builds/windows/windows-server-2022/windows-server.pkr.hcl b/builds/windows/windows-server-2022/windows-server.pkr.hcl index 702d3d3e2..8e4b5715d 100644 --- a/builds/windows/windows-server-2022/windows-server.pkr.hcl +++ b/builds/windows/windows-server-2022/windows-server.pkr.hcl @@ -72,14 +72,22 @@ source "vsphere-iso" "windows-server-standard-core" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2022 SERVERSTANDARDCORE", kms_key = "VDYBN-27WPP-V4HQT-9VMD4-VMK7H", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2022 SERVERSTANDARDCORE" + kms_key = "VDYBN-27WPP-V4HQT-9VMD4-VMK7H" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -151,14 +159,22 @@ source "vsphere-iso" "windows-server-standard-dexp" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2022 SERVERSTANDARD", kms_key = "VDYBN-27WPP-V4HQT-9VMD4-VMK7H", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2022 SERVERSTANDARD" + kms_key = "VDYBN-27WPP-V4HQT-9VMD4-VMK7H" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -230,14 +246,22 @@ source "vsphere-iso" "windows-server-datacenter-core" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2022 SERVERDATACENTERCORE", kms_key = "WX4NM-KYWYW-QJJR4-XV3QB-6VM33", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2022 SERVERDATACENTERCORE" + kms_key = "WX4NM-KYWYW-QJJR4-XV3QB-6VM33" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -309,14 +333,22 @@ source "vsphere-iso" "windows-server-datacenter-dexp" { notes = "Built by HashiCorp Packer on ${local.buildtime}." // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" cd_files = [ "${path.cwd}/scripts/${var.vm_guest_os_family}/", "${path.cwd}/certificates/" ] cd_content = { - "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { os_image = "Windows Server 2022 SERVERDATACENTER", kms_key = "WX4NM-KYWYW-QJJR4-XV3QB-6VM33", build_username = var.build_username, build_password = var.build_password, 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 }) + "autounattend.xml" = templatefile("${abspath(path.root)}/data/autounattend.pkrtpl.hcl", { + os_image = "Windows Server 2022 SERVERDATACENTER" + kms_key = "WX4NM-KYWYW-QJJR4-XV3QB-6VM33" + build_username = var.build_username + build_password = var.build_password + 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 and Provisioning Settings @@ -393,7 +425,7 @@ build { } post-processor "manifest" { - output = "${local.path_manifest}${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_member}.json" + output = "${local.path_manifest}${local.buildtime} ${var.vm_guest_os_family}-${var.vm_guest_os_member}.json" strip_path = false } } \ No newline at end of file diff --git a/scripts/linux/redhat-variant.sh b/scripts/linux/redhat-derivative.sh similarity index 100% rename from scripts/linux/redhat-variant.sh rename to scripts/linux/redhat-derivative.sh