From a982647c41fbfd6e83b432418d155dfd8bcfdc2c Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Wed, 15 Sep 2021 22:09:19 -0400 Subject: [PATCH] Update for release v21.09.1 (#38) * Updated the defaults in `common.pkvars.hcl` to use hardware version 19, which provides the best performance and latest features available in ESXi 7.0 U2. * Updated the Rocky Linux build to use UEFI; however without secure boot. * Refactored all builds to pass the language, keyboard, and timezone to the configuration files. * Refactored all builds with input variable definitions separated into `variables.pkr.hcl`. * Refactored all builds to use `.auto.pkvars.hcl` for input variables the and `.pkr.hcl` for the template configurations, with simplified names for ``. * Refactored all builds to use `${path.cwd}/output/` as the path for the manifest post-processor. --- CHANGELOG.md | 20 +- README.md | 10 +- builds/common.pkrvars.hcl | 2 +- builds/linux/almalinux-8/http/ks.pkrtpl.hcl | 6 +- ...s.hcl => linux-almalinux.auto.pkrvars.hcl} | 15 +- .../linux/almalinux-8/linux-almalinux.pkr.hcl | 126 +++++ builds/linux/almalinux-8/output/.placeholder | 0 ...{almalinux-8.pkr.hcl => variables.pkr.hcl} | 162 ++----- .../linux/centos-linux-8/http/ks.pkrtpl.hcl | 8 +- ...cl => linux-centos-linux.auto.pkrvars.hcl} | 15 +- .../centos-linux-8/linux-centos-linux.pkr.hcl | 126 +++++ .../linux/centos-linux-8/output/.placeholder | 0 ...ntos-linux-8.pkr.hcl => variables.pkr.hcl} | 164 ++----- .../linux/centos-stream-8/http/ks.pkrtpl.hcl | 6 +- ...l => linux-centos-stream.auto.pkrvars.hcl} | 15 +- .../linux-centos-stream.pkr.hcl | 126 +++++ .../linux/centos-stream-8/output/.placeholder | 0 ...tos-stream-8.pkr.hcl => variables.pkr.hcl} | 164 ++----- builds/linux/photon-4/http/ks.pkrtpl.hcl | 20 +- ...vars.hcl => linux-photon.auto.pkrvars.hcl} | 4 +- builds/linux/photon-4/linux-photon.pkr.hcl | 127 +++++ builds/linux/photon-4/output/.placeholder | 0 .../{photon-4.pkr.hcl => variables.pkr.hcl} | 147 +----- .../linux/redhat-linux-8/http/ks.pkrtpl.hcl | 6 +- ...cl => linux-redhat-linux.auto.pkrvars.hcl} | 15 +- .../redhat-linux-8/linux-redhat-linux.pkr.hcl | 128 +++++ .../linux/redhat-linux-8/output/.placeholder | 0 ...dhat-linux-8.pkr.hcl => variables.pkr.hcl} | 166 ++----- builds/linux/rocky-linux-8/http/ks.pkrtpl.hcl | 6 +- ...hcl => linux-rocky-linux.auto.pkrvars.hcl} | 17 +- .../rocky-linux-8/linux-rocky-linux.pkr.hcl | 126 +++++ .../linux/rocky-linux-8/output/.placeholder | 0 ...ocky-linux-8.pkr.hcl => variables.pkr.hcl} | 166 ++----- .../http/ks.pkrtpl.hcl | 6 +- ...l => linux-ubuntu-server.auto.pkrvars.hcl} | 17 +- .../linux-ubuntu-server.pkr.hcl | 139 ++++++ .../output/.placeholder | 0 .../ubuntu-server-18-04-lts.pkr.hcl | 449 ------------------ .../ubuntu-server-18-04-lts/variables.pkr.hcl | 332 +++++++++++++ .../http/user-data.pkrtpl.hcl | 8 +- ...l => linux-ubuntu-server.auto.pkrvars.hcl} | 15 +- .../linux-ubuntu-server.pkr.hcl | 127 +++++ .../output/.placeholder | 0 ...er-20-04-lts.pkr.hcl => variables.pkr.hcl} | 163 ++----- .../cd/autounattend.pkrtpl.hcl | 16 +- .../windows-server-2016/output/.placeholder | 0 .../windows-server-2016/variables.pkr.hcl | 363 ++++++++++++++ ...rs.hcl => windows-server.auto.pkrvars.hcl} | 3 + ...er-2016.pkr.hcl => windows-server.pkr.hcl} | 371 +-------------- .../cd/autounattend.pkrtpl.hcl | 14 +- .../windows-server-2019/output/.placeholder | 0 .../windows-server-2019/variables.pkr.hcl | 357 ++++++++++++++ ...rs.hcl => windows-server.auto.pkrvars.hcl} | 3 + ...er-2019.pkr.hcl => windows-server.pkr.hcl} | 383 +-------------- .../cd/autounattend.pkrtpl.hcl | 16 +- .../windows-server-2022/output/.placeholder | 0 .../windows-server-2022/variables.pkr.hcl | 357 ++++++++++++++ ...rs.hcl => windows-server.auto.pkrvars.hcl} | 3 + ...er-2022.pkr.hcl => windows-server.pkr.hcl} | 365 +------------- manifests/PLACEHOLDER.md | 1 - 60 files changed, 2837 insertions(+), 2564 deletions(-) rename builds/linux/almalinux-8/{variables.auto.pkrvars.hcl => linux-almalinux.auto.pkrvars.hcl} (79%) create mode 100644 builds/linux/almalinux-8/linux-almalinux.pkr.hcl create mode 100644 builds/linux/almalinux-8/output/.placeholder rename builds/linux/almalinux-8/{almalinux-8.pkr.hcl => variables.pkr.hcl} (62%) rename builds/linux/centos-linux-8/{variables.auto.pkrvars.hcl => linux-centos-linux.auto.pkrvars.hcl} (79%) create mode 100644 builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl create mode 100644 builds/linux/centos-linux-8/output/.placeholder rename builds/linux/centos-linux-8/{centos-linux-8.pkr.hcl => variables.pkr.hcl} (62%) rename builds/linux/centos-stream-8/{variables.auto.pkrvars.hcl => linux-centos-stream.auto.pkrvars.hcl} (79%) create mode 100644 builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl create mode 100644 builds/linux/centos-stream-8/output/.placeholder rename builds/linux/centos-stream-8/{centos-stream-8.pkr.hcl => variables.pkr.hcl} (62%) rename builds/linux/photon-4/{variables.auto.pkrvars.hcl => linux-photon.auto.pkrvars.hcl} (95%) create mode 100644 builds/linux/photon-4/linux-photon.pkr.hcl create mode 100644 builds/linux/photon-4/output/.placeholder rename builds/linux/photon-4/{photon-4.pkr.hcl => variables.pkr.hcl} (61%) rename builds/linux/redhat-linux-8/{variables.auto.pkrvars.hcl => linux-redhat-linux.auto.pkrvars.hcl} (79%) create mode 100644 builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl create mode 100644 builds/linux/redhat-linux-8/output/.placeholder rename builds/linux/redhat-linux-8/{redhat-linux-8.pkr.hcl => variables.pkr.hcl} (62%) rename builds/linux/rocky-linux-8/{variables.auto.pkrvars.hcl => linux-rocky-linux.auto.pkrvars.hcl} (77%) create mode 100644 builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl create mode 100644 builds/linux/rocky-linux-8/output/.placeholder rename builds/linux/rocky-linux-8/{rocky-linux-8.pkr.hcl => variables.pkr.hcl} (62%) rename builds/linux/ubuntu-server-18-04-lts/{variables.auto.pkrvars.hcl => linux-ubuntu-server.auto.pkrvars.hcl} (72%) create mode 100644 builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl create mode 100644 builds/linux/ubuntu-server-18-04-lts/output/.placeholder delete mode 100644 builds/linux/ubuntu-server-18-04-lts/ubuntu-server-18-04-lts.pkr.hcl create mode 100644 builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl rename builds/linux/ubuntu-server-20-04-lts/{variables.auto.pkrvars.hcl => linux-ubuntu-server.auto.pkrvars.hcl} (79%) create mode 100644 builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl create mode 100644 builds/linux/ubuntu-server-20-04-lts/output/.placeholder rename builds/linux/ubuntu-server-20-04-lts/{ubuntu-server-20-04-lts.pkr.hcl => variables.pkr.hcl} (62%) create mode 100644 builds/windows/windows-server-2016/output/.placeholder create mode 100644 builds/windows/windows-server-2016/variables.pkr.hcl rename builds/windows/windows-server-2016/{variables.auto.pkrvars.hcl => windows-server.auto.pkrvars.hcl} (94%) rename builds/windows/windows-server-2016/{windows-server-2016.pkr.hcl => windows-server.pkr.hcl} (55%) create mode 100644 builds/windows/windows-server-2019/output/.placeholder create mode 100644 builds/windows/windows-server-2019/variables.pkr.hcl rename builds/windows/windows-server-2019/{variables.auto.pkrvars.hcl => windows-server.auto.pkrvars.hcl} (94%) rename builds/windows/windows-server-2019/{windows-server-2019.pkr.hcl => windows-server.pkr.hcl} (52%) create mode 100644 builds/windows/windows-server-2022/output/.placeholder create mode 100644 builds/windows/windows-server-2022/variables.pkr.hcl rename builds/windows/windows-server-2022/{variables.auto.pkrvars.hcl => windows-server.auto.pkrvars.hcl} (94%) rename builds/windows/windows-server-2022/{windows-server-2022.pkr.hcl => windows-server.pkr.hcl} (56%) delete mode 100644 manifests/PLACEHOLDER.md diff --git a/CHANGELOG.md b/CHANGELOG.md index cf9be6dd0..0fd9ddce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,19 @@ ![Rainpole](icon.png) -## Release: `21.09` +## Release: `v21.09.1` +September 16, 2021 +* Refactored issue templates to use GitHub custom issue forms. +* Refactored all builds to pass the language, keyboard, and timezone to the configuration files. +* Updated the Rocky Linux build to use UEFI; however without secure boot. +* Updated the defaults in `common.pkvars.hcl` to use hardware version 19, which provides the best performance and latest features available in ESXi 7.0 U2. Refer to the VMware vSphere 7.0 [product documentation](https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vm_admin.doc/GUID-789C3913-1053-4850-A0F0-E29C3D32B6DA.html) if using a previous release +* Refactored all builds with input variable definitions separated into `variables.pkr.hcl`. +* Refactored all builds to use `.auto.pkvars.hcl` for input variables the and `.pkr.hcl` for the template configurations, with simplified names for ``. +* Refactored all builds to use `${path.cwd}/output/` as the path for the manifest post-processor. +* Added disclaimers and updated descriptions in script files. +* Updated README.md. + +## Release: `v21.09` September 7, 2021 * Added support for Microsoft Windows Server 2022 machine image builds. * Refactored configuration files to be generated using templates. Reduces the number of files and passes variables into the `.pkrtpl.hcl` content. @@ -15,7 +27,7 @@ September 7, 2021 * Updated CONTRIBUTING.md. * Updated README.md. -## Release: `21.08` +## Release: `v21.08` August 18, 2021 * Moved `vsphere.pkrvars.hcl` and `rhsm.pkrvars.hcl` to the `builds` directory. * Isolated variables to simplify updates to common settings with `builds/common.pkrvars.hcl`. @@ -40,7 +52,7 @@ August 18, 2021 * Added MAINTAINERS.md. * Updated README.md. -## Release: `21.07` +## Release: `v21.07` July 21, 2021 * Added support for [VMware Photon OS](https://vmware.github.io/photon/) 4. * Added [support](https://github.com/rainpole/packer-vsphere/issues/18) for [AlmaLinux](http://almalinux.org) 8. @@ -50,6 +62,6 @@ July 21, 2021 * Added the Packer block to all builds with `required_versions >= "1.7.3"` for Packer. * Added the Packer block for Windows builds with `required_plugins` and `version = "0.12.0"` for the [Windows-Update plugin](https://github.com/rgl/packer-plugin-windows-update). -## Release: `20.11` +## Release: `v20.11` November 26, 2020 * Initial release. \ No newline at end of file diff --git a/README.md b/README.md index 3a6d851a8..96f9f9e0a 100644 --- a/README.md +++ b/README.md @@ -96,13 +96,13 @@ The directory structure of the repository. │ ├── linux │ │ └── distribution-version │ │ ├── *.pkr.hcl -│ │ ├── variables.auto.pkrvars.hcl +│ │ ├── *.auto.pkrvars.hcl │ │ └── http │ │ └── ks.pkrtpl.hcl │ └── windows │ └── version │ ├── *.pkr.hcl -│ ├── variables.auto.pkrvars.hcl +│ ├── *.auto.pkrvars.hcl │ └── cd │ └── autounattend.pkrtpl.hcl ├── certificates @@ -292,7 +292,7 @@ These variables are **only** used if you are performing a Red Hat Enterprise Lin #### **Machine Image Variables** -Edit the `variables.auto.pkvars.hcl` file in each `builds//` folder to configure the following virtual machine hardware settings, as required: +Edit the `*.auto.pkvars.hcl` file in each `builds//` folder to configure the following virtual machine hardware settings, as required: * CPU Sockets `(init)` * CPU Cores `(init)` @@ -305,7 +305,7 @@ Edit the `variables.auto.pkvars.hcl` file in each `builds//` folder #### **Using Environmental Variables** -Some of the variables may include sensitive information and environmental data that you would prefer not to save to clear text files. You can save use environmental variables before running a build using the example below: +Some of the variables may include sensitive information and environmental data that you would prefer not to save to clear text files. You can add there to environmental variables using the example below: ``` export PKR_VAR_vsphere_endpoint="" @@ -485,4 +485,4 @@ Happy building!!! [vsphere-content-library]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vm_admin.doc/GUID-254B2CE8-20A8-43F0-90E8-3F6776C2C896.html [vsphere-guestosid]: https://vdc-download.vmware.com/vmwb-repository/dcr-public/b50dcbbf-051d-4204-a3e7-e1b618c1e384/538cf2ec-b34f-4bae-a332-3820ef9e7773/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html [vsphere-efi]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.security.doc/GUID-898217D4-689D-4EB5-866C-888353FE241C.html -[vsphere-upload]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.storage.doc/GUID-58D77EA5-50D9-4A8E-A15A-D7B3ABA11B87.html?hWord=N4IghgNiBcIK4AcIHswBMAEAzAlhApgM4gC+QA +[vsphere-upload]: https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.storage.doc/GUID-58D77EA5-50D9-4A8E-A15A-D7B3ABA11B87.html?hWord=N4IghgNiBcIK4AcIHswBMAEAzAlhApgM4gC+QA \ No newline at end of file diff --git a/builds/common.pkrvars.hcl b/builds/common.pkrvars.hcl index 90477859b..0984d8401 100644 --- a/builds/common.pkrvars.hcl +++ b/builds/common.pkrvars.hcl @@ -5,7 +5,7 @@ */ // Virtual Machine Settings -common_vm_version = 18 +common_vm_version = 19 common_tools_upgrade_policy = true common_remove_cdrom = true diff --git a/builds/linux/almalinux-8/http/ks.pkrtpl.hcl b/builds/linux/almalinux-8/http/ks.pkrtpl.hcl index eb5a86277..99c91eabc 100644 --- a/builds/linux/almalinux-8/http/ks.pkrtpl.hcl +++ b/builds/linux/almalinux-8/http/ks.pkrtpl.hcl @@ -1,9 +1,9 @@ # AlmaLinux 8 install eula --agreed -lang en_US -keyboard us -timezone UTC +lang ${vm_guest_os_language} +keyboard ${vm_guest_os_keyboard} +timezone ${vm_guest_os_timezone} rootpw --lock user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel cdrom diff --git a/builds/linux/almalinux-8/variables.auto.pkrvars.hcl b/builds/linux/almalinux-8/linux-almalinux.auto.pkrvars.hcl similarity index 79% rename from builds/linux/almalinux-8/variables.auto.pkrvars.hcl rename to builds/linux/almalinux-8/linux-almalinux.auto.pkrvars.hcl index d24079838..b6a4e9b58 100644 --- a/builds/linux/almalinux-8/variables.auto.pkrvars.hcl +++ b/builds/linux/almalinux-8/linux-almalinux.auto.pkrvars.hcl @@ -4,10 +4,13 @@ */ // Guest Operating System Metadata -vm_guest_os_family = "linux" -vm_guest_os_vendor = "almalinux" -vm_guest_os_member = "server" -vm_guest_os_version = "8" +vm_guest_os_language = "en_US" +vm_guest_os_keyboard = "us" +vm_guest_os_timezone = "UTC" +vm_guest_os_family = "linux" +vm_guest_os_vendor = "almalinux" +vm_guest_os_member = "server" +vm_guest_os_version = "8" // Virtual Machine Guest Operating System Setting vm_guest_os_type = "centos8_64Guest" @@ -30,8 +33,8 @@ iso_file = "iso-linux-almalinux-8.iso" iso_checksum = "44f56b309fa0cccf41f4d8a5ca3c9b91bb7da510ff8d8faf93fadef9262df872cb824aa7499c5ada5a7ae743be6b38261ed458c465d84e2504e38ca6f05107d7" // Boot Settings -vm_boot_order = "disk,cdrom" -vm_boot_wait = "2s" +vm_boot_order = "disk,cdrom" +vm_boot_wait = "2s" // Communicator Settings communicator_port = 22 diff --git a/builds/linux/almalinux-8/linux-almalinux.pkr.hcl b/builds/linux/almalinux-8/linux-almalinux.pkr.hcl new file mode 100644 index 000000000..c9f83a89e --- /dev/null +++ b/builds/linux/almalinux-8/linux-almalinux.pkr.hcl @@ -0,0 +1,126 @@ +/* + DESCRIPTION: + AlmaLinux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.7.4" + required_plugins { + vsphere = { + version = ">= v1.0.1" + source = "github.com/hashicorp/vsphere" + } + } +} + +// BLOCK: locals +// Defines the local variables. + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "vsphere-iso" "linux-almalinux" { + + // vCenter Server Endpoint Settings and Credentials + vcenter_server = var.vsphere_endpoint + username = var.vsphere_username + password = var.vsphere_password + insecure_connection = var.vsphere_insecure_connection + + // vSphere Settings + datacenter = var.vsphere_datacenter + cluster = var.vsphere_cluster + datastore = var.vsphere_datastore + folder = var.vsphere_folder + + // Virtual Machine Settings + guest_os_type = var.vm_guest_os_type + vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" + firmware = var.vm_firmware + CPUs = var.vm_cpu_sockets + cpu_cores = var.vm_cpu_cores + CPU_hot_plug = var.vm_cpu_hot_add + RAM = var.vm_mem_size + RAM_hot_plug = var.vm_mem_hot_add + cdrom_type = var.vm_cdrom_type + disk_controller_type = var.vm_disk_controller_type + storage { + disk_size = var.vm_disk_size + disk_thin_provisioned = var.vm_disk_thin_provisioned + } + network_adapters { + network = var.vsphere_network + network_card = var.vm_network_card + } + vm_version = var.common_vm_version + remove_cdrom = var.common_remove_cdrom + tools_upgrade_policy = var.common_tools_upgrade_policy + notes = "Built by HashiCorp Packer on ${local.buildtime}." + + // Removable Media Settings + iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + http_content = { + "/ks.cfg" = templatefile("${path.cwd}/http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted, vm_guest_os_language = var.vm_guest_os_language, vm_guest_os_keyboard = var.vm_guest_os_keyboard, vm_guest_os_timezone = var.vm_guest_os_timezone }) + } + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = ["up", "e", "", "text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "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 + + // Communicator Settings and Credentials + communicator = "ssh" + ssh_username = var.build_username + ssh_password = var.build_password + ssh_port = var.communicator_port + ssh_timeout = var.communicator_timeout + + // Template and Content Library Settings + convert_to_template = var.common_template_conversion + content_library_destination { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } +} + +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = ["source.vsphere-iso.linux-almalinux"] + + provisioner "file" { + destination = "/tmp/root-ca.crt" + source = "../../../certificates/root-ca.crt" + } + + provisioner "shell" { + execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" + environment_vars = [ + "BUILD_USERNAME=${var.build_username}", + "BUILD_KEY=${var.build_key}", + "ANSIBLE_USERNAME=${var.ansible_username}", + "ANSIBLE_KEY=${var.ansible_key}" + ] + scripts = var.scripts + } + + post-processor "manifest" { + output = "${path.cwd}/output/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + strip_path = false + } +} \ No newline at end of file diff --git a/builds/linux/almalinux-8/output/.placeholder b/builds/linux/almalinux-8/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/linux/almalinux-8/almalinux-8.pkr.hcl b/builds/linux/almalinux-8/variables.pkr.hcl similarity index 62% rename from builds/linux/almalinux-8/almalinux-8.pkr.hcl rename to builds/linux/almalinux-8/variables.pkr.hcl index 1d58e7556..545074a79 100644 --- a/builds/linux/almalinux-8/almalinux-8.pkr.hcl +++ b/builds/linux/almalinux-8/variables.pkr.hcl @@ -1,21 +1,8 @@ /* DESCRIPTION: - AlmaLinux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). + AlmaLinux 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ -// BLOCK: packer -// The Packer configuration. - -packer { - required_version = ">= 1.7.4" - required_plugins { - vsphere = { - version = ">= v1.0.1" - source = "github.com/hashicorp/vsphere" - } - } -} - // BLOCK: variable // Defines the input variables. @@ -68,19 +55,37 @@ variable "vsphere_network" { variable "vsphere_folder" { type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" } // Virtual Machine Settings +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en_US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "us" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + variable "vm_guest_os_family" { type = string - description = "The guest operating system family. Used for naming. (e.g.'linux')" + description = "The guest operating system family. Used for naming and VMware tools. (e.g.'linux')" } variable "vm_guest_os_vendor" { type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'almalinux')" + description = "The guest operating system vendor. Used for naming . (e.g. 'almalinux')" } variable "vm_guest_os_member" { @@ -100,7 +105,7 @@ variable "vm_guest_os_type" { variable "vm_firmware" { type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" default = "efi-secure" } @@ -216,7 +221,7 @@ variable "common_iso_path" { variable "common_iso_hash" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" } variable "iso_file" { @@ -243,13 +248,13 @@ variable "common_http_port_max" { variable "vm_boot_order" { type = string - description = "The time to wait before boot." + description = "The boot order for virtual machines devices." default = "disk,cdrom" } variable "vm_boot_wait" { type = string - description = "The boot order for virtual machines devices." + description = "The time to wait before boot." } variable "common_ip_wait_timeout" { @@ -278,13 +283,13 @@ variable "build_password" { variable "build_password_encrypted" { type = string - description = "The encrypted password for building the guest operating system." + description = "The encrypted password to login to the guest operating system." sensitive = true } variable "build_key" { type = string - description = "The key to login to the guest operating system." + description = "The public key to login to the guest operating system." sensitive = true } @@ -308,7 +313,7 @@ variable "ansible_username" { variable "ansible_key" { type = string - description = "The key for Ansible to login to the guest operating system." + description = "The public key for Ansible to login to the guest operating system." sensitive = true } @@ -324,113 +329,4 @@ variable "inline" { type = list(string) description = "A list of commands to execute." default = [] -} - -// BLOCK: locals -// Defines the local variables. - -locals { - buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) -} - -// BLOCK: source -// Defines the builder configuration blocks. - -source "vsphere-iso" "linux-almalinux" { - - // vCenter Server Endpoint Settings and Credentials - vcenter_server = var.vsphere_endpoint - username = var.vsphere_username - password = var.vsphere_password - insecure_connection = var.vsphere_insecure_connection - - // vSphere Settings - datacenter = var.vsphere_datacenter - cluster = var.vsphere_cluster - datastore = var.vsphere_datastore - folder = var.vsphere_folder - - // Virtual Machine Settings - guest_os_type = var.vm_guest_os_type - vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" - firmware = var.vm_firmware - CPUs = var.vm_cpu_sockets - cpu_cores = var.vm_cpu_cores - CPU_hot_plug = var.vm_cpu_hot_add - RAM = var.vm_mem_size - RAM_hot_plug = var.vm_mem_hot_add - cdrom_type = var.vm_cdrom_type - disk_controller_type = var.vm_disk_controller_type - storage { - disk_size = var.vm_disk_size - disk_thin_provisioned = var.vm_disk_thin_provisioned - } - network_adapters { - network = var.vsphere_network - network_card = var.vm_network_card - } - vm_version = var.common_vm_version - remove_cdrom = var.common_remove_cdrom - tools_upgrade_policy = var.common_tools_upgrade_policy - notes = "Built by HashiCorp Packer on ${local.buildtime}." - - // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" - - // Boot and Provisioning Settings - http_port_min = var.common_http_port_min - http_port_max = var.common_http_port_max - http_content = { - "/ks.cfg" = templatefile("http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted }) - } - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["up", "e", "", "text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "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 - - // Communicator Settings and Credentials - communicator = "ssh" - ssh_username = var.build_username - ssh_password = var.build_password - ssh_port = var.communicator_port - ssh_timeout = var.communicator_timeout - - // Template and Content Library Settings - convert_to_template = var.common_template_conversion - content_library_destination { - library = var.common_content_library_name - ovf = var.common_content_library_ovf - destroy = var.common_content_library_destroy - } -} - -// BLOCK: build -// Defines the builders to run, provisioners, and post-processors. - -build { - sources = ["source.vsphere-iso.linux-almalinux"] - - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "../../../certificates/root-ca.crt" - } - - provisioner "shell" { - execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" - environment_vars = [ - "BUILD_USERNAME=${var.build_username}", - "BUILD_KEY=${var.build_key}", - "ANSIBLE_USERNAME=${var.ansible_username}", - "ANSIBLE_KEY=${var.ansible_key}" - ] - scripts = var.scripts - } - - post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" - strip_path = false - } } \ No newline at end of file diff --git a/builds/linux/centos-linux-8/http/ks.pkrtpl.hcl b/builds/linux/centos-linux-8/http/ks.pkrtpl.hcl index 0748b2c7c..54a3981aa 100644 --- a/builds/linux/centos-linux-8/http/ks.pkrtpl.hcl +++ b/builds/linux/centos-linux-8/http/ks.pkrtpl.hcl @@ -1,11 +1,11 @@ # CentOS Linux 8 install eula --agreed -lang en_US -keyboard us -timezone UTC +lang ${vm_guest_os_language} +keyboard ${vm_guest_os_keyboard} +timezone ${vm_guest_os_timezone} rootpw --lock -user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel +user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel cdrom reboot --eject bootloader --location=mbr --append="rhgb quiet crashkernel=auto" diff --git a/builds/linux/centos-linux-8/variables.auto.pkrvars.hcl b/builds/linux/centos-linux-8/linux-centos-linux.auto.pkrvars.hcl similarity index 79% rename from builds/linux/centos-linux-8/variables.auto.pkrvars.hcl rename to builds/linux/centos-linux-8/linux-centos-linux.auto.pkrvars.hcl index 63dee8acc..41946fc5f 100644 --- a/builds/linux/centos-linux-8/variables.auto.pkrvars.hcl +++ b/builds/linux/centos-linux-8/linux-centos-linux.auto.pkrvars.hcl @@ -4,10 +4,13 @@ */ // Guest Operating System Metadata -vm_guest_os_family = "linux" -vm_guest_os_vendor = "centos-linux" -vm_guest_os_member = "server" -vm_guest_os_version = "8" +vm_guest_os_language = "en_US" +vm_guest_os_keyboard = "us" +vm_guest_os_timezone = "UTC" +vm_guest_os_family = "linux" +vm_guest_os_vendor = "centos-linux" +vm_guest_os_member = "server" +vm_guest_os_version = "8" // Virtual Machine Guest Operating System Setting vm_guest_os_type = "centos8_64Guest" @@ -30,8 +33,8 @@ iso_file = "iso-linux-centos-linux-8.iso" iso_checksum = "ff1164dc26ba47616f2b26a18158398a7d7930487770a8bb9e573d5758e01255ebc11db68c22976abe684a857083a0fae445e9d41d11a24a2073cdb1b500ae9a" // Boot Settings -vm_boot_order = "disk,cdrom" -vm_boot_wait = "2s" +vm_boot_order = "disk,cdrom" +vm_boot_wait = "2s" // Communicator Settings communicator_port = 22 diff --git a/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl b/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl new file mode 100644 index 000000000..42560c98d --- /dev/null +++ b/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl @@ -0,0 +1,126 @@ +/* + DESCRIPTION: + CentOS Linux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.7.4" + required_plugins { + vsphere = { + version = ">= v1.0.1" + source = "github.com/hashicorp/vsphere" + } + } +} + +// BLOCK: locals +// Defines the local variables. + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "vsphere-iso" "linux-centos-linux" { + + // vCenter Server Endpoint Settings and Credentials + vcenter_server = var.vsphere_endpoint + username = var.vsphere_username + password = var.vsphere_password + insecure_connection = var.vsphere_insecure_connection + + // vSphere Settings + datacenter = var.vsphere_datacenter + cluster = var.vsphere_cluster + datastore = var.vsphere_datastore + folder = var.vsphere_folder + + // Virtual Machine Settings + guest_os_type = var.vm_guest_os_type + vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" + firmware = var.vm_firmware + CPUs = var.vm_cpu_sockets + cpu_cores = var.vm_cpu_cores + CPU_hot_plug = var.vm_cpu_hot_add + RAM = var.vm_mem_size + RAM_hot_plug = var.vm_mem_hot_add + cdrom_type = var.vm_cdrom_type + disk_controller_type = var.vm_disk_controller_type + storage { + disk_size = var.vm_disk_size + disk_thin_provisioned = var.vm_disk_thin_provisioned + } + network_adapters { + network = var.vsphere_network + network_card = var.vm_network_card + } + vm_version = var.common_vm_version + remove_cdrom = var.common_remove_cdrom + tools_upgrade_policy = var.common_tools_upgrade_policy + notes = "Built by HashiCorp Packer on ${local.buildtime}." + + // Removable Media Settings + iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + http_content = { + "/ks.cfg" = templatefile("${path.cwd}/http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted, vm_guest_os_language = var.vm_guest_os_language, vm_guest_os_keyboard = var.vm_guest_os_keyboard, vm_guest_os_timezone = var.vm_guest_os_timezone }) + } + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = ["up", "e", "", "text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "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 + + // Communicator Settings and Credentials + communicator = "ssh" + ssh_username = var.build_username + ssh_password = var.build_password + ssh_port = var.communicator_port + ssh_timeout = var.communicator_timeout + + // Template and Content Library Settings + convert_to_template = var.common_template_conversion + content_library_destination { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } +} + +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = ["source.vsphere-iso.linux-centos-linux"] + + provisioner "file" { + destination = "/tmp/root-ca.crt" + source = "../../../certificates/root-ca.crt" + } + + provisioner "shell" { + execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" + environment_vars = [ + "BUILD_USERNAME=${var.build_username}", + "BUILD_KEY=${var.build_key}", + "ANSIBLE_USERNAME=${var.ansible_username}", + "ANSIBLE_KEY=${var.ansible_key}" + ] + scripts = var.scripts + } + + post-processor "manifest" { + output = "${path.cwd}/output/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + strip_path = false + } +} diff --git a/builds/linux/centos-linux-8/output/.placeholder b/builds/linux/centos-linux-8/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/linux/centos-linux-8/centos-linux-8.pkr.hcl b/builds/linux/centos-linux-8/variables.pkr.hcl similarity index 62% rename from builds/linux/centos-linux-8/centos-linux-8.pkr.hcl rename to builds/linux/centos-linux-8/variables.pkr.hcl index f0a03dbb9..df4c61b6f 100644 --- a/builds/linux/centos-linux-8/centos-linux-8.pkr.hcl +++ b/builds/linux/centos-linux-8/variables.pkr.hcl @@ -1,21 +1,8 @@ /* DESCRIPTION: - CentOS Linux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). + CentOS Linux 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ -// BLOCK: packer -// The Packer configuration. - -packer { - required_version = ">= 1.7.4" - required_plugins { - vsphere = { - version = ">= v1.0.1" - source = "github.com/hashicorp/vsphere" - } - } -} - // BLOCK: variable // Defines the input variables. @@ -68,19 +55,37 @@ variable "vsphere_network" { variable "vsphere_folder" { type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" } // Virtual Machine Settings +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en_US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "us" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + variable "vm_guest_os_family" { type = string - description = "The guest operating system family. Used for naming. (e.g.'linux')" + description = "The guest operating system family. Used for naming and VMware tools. (e.g.'linux')" } variable "vm_guest_os_vendor" { type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'centos-linux')" + description = "The guest operating system vendor. Used for naming . (e.g. 'centos-linux')" } variable "vm_guest_os_member" { @@ -100,7 +105,7 @@ variable "vm_guest_os_type" { variable "vm_firmware" { type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" default = "efi-secure" } @@ -216,7 +221,7 @@ variable "common_iso_path" { variable "common_iso_hash" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" } variable "iso_file" { @@ -243,13 +248,13 @@ variable "common_http_port_max" { variable "vm_boot_order" { type = string - description = "The time to wait before boot." + description = "The boot order for virtual machines devices." default = "disk,cdrom" } variable "vm_boot_wait" { type = string - description = "The boot order for virtual machines devices." + description = "The time to wait before boot." } variable "common_ip_wait_timeout" { @@ -278,13 +283,13 @@ variable "build_password" { variable "build_password_encrypted" { type = string - description = "The encrypted password for building the guest operating system." + description = "The encrypted password to login to the guest operating system." sensitive = true } variable "build_key" { type = string - description = "The key to login to the guest operating system." + description = "The public key to login to the guest operating system." sensitive = true } @@ -308,7 +313,7 @@ variable "ansible_username" { variable "ansible_key" { type = string - description = "The key for Ansible to login to the guest operating system." + description = "The public key for Ansible to login to the guest operating system." sensitive = true } @@ -324,113 +329,4 @@ variable "inline" { type = list(string) description = "A list of commands to execute." default = [] -} - -// BLOCK: locals -// Defines the local variables. - -locals { - buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) -} - -// BLOCK: source -// Defines the builder configuration blocks. - -source "vsphere-iso" "linux-centos-linux" { - - // vCenter Server Endpoint Settings and Credentials - vcenter_server = var.vsphere_endpoint - username = var.vsphere_username - password = var.vsphere_password - insecure_connection = var.vsphere_insecure_connection - - // vSphere Settings - datacenter = var.vsphere_datacenter - cluster = var.vsphere_cluster - datastore = var.vsphere_datastore - folder = var.vsphere_folder - - // Virtual Machine Settings - guest_os_type = var.vm_guest_os_type - vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" - firmware = var.vm_firmware - CPUs = var.vm_cpu_sockets - cpu_cores = var.vm_cpu_cores - CPU_hot_plug = var.vm_cpu_hot_add - RAM = var.vm_mem_size - RAM_hot_plug = var.vm_mem_hot_add - cdrom_type = var.vm_cdrom_type - disk_controller_type = var.vm_disk_controller_type - storage { - disk_size = var.vm_disk_size - disk_thin_provisioned = var.vm_disk_thin_provisioned - } - network_adapters { - network = var.vsphere_network - network_card = var.vm_network_card - } - vm_version = var.common_vm_version - remove_cdrom = var.common_remove_cdrom - tools_upgrade_policy = var.common_tools_upgrade_policy - notes = "Built by HashiCorp Packer on ${local.buildtime}." - - // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" - - // Boot and Provisioning Settings - http_port_min = var.common_http_port_min - http_port_max = var.common_http_port_max - http_content = { - "/ks.cfg" = templatefile("http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted }) - } - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["up", "e", "", "text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "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 - - // Communicator Settings and Credentials - communicator = "ssh" - ssh_username = var.build_username - ssh_password = var.build_password - ssh_port = var.communicator_port - ssh_timeout = var.communicator_timeout - - // Template and Content Library Settings - convert_to_template = var.common_template_conversion - content_library_destination { - library = var.common_content_library_name - ovf = var.common_content_library_ovf - destroy = var.common_content_library_destroy - } -} - -// BLOCK: build -// Defines the builders to run, provisioners, and post-processors. - -build { - sources = ["source.vsphere-iso.linux-centos-linux"] - - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "../../../certificates/root-ca.crt" - } - - provisioner "shell" { - execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" - environment_vars = [ - "BUILD_USERNAME=${var.build_username}", - "BUILD_KEY=${var.build_key}", - "ANSIBLE_USERNAME=${var.ansible_username}", - "ANSIBLE_KEY=${var.ansible_key}" - ] - scripts = var.scripts - } - - post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" - strip_path = false - } -} +} \ No newline at end of file diff --git a/builds/linux/centos-stream-8/http/ks.pkrtpl.hcl b/builds/linux/centos-stream-8/http/ks.pkrtpl.hcl index 3de0e1905..dde1abdf7 100644 --- a/builds/linux/centos-stream-8/http/ks.pkrtpl.hcl +++ b/builds/linux/centos-stream-8/http/ks.pkrtpl.hcl @@ -1,9 +1,9 @@ # CentOS Stream 8 install eula --agreed -lang en_US -keyboard us -timezone UTC +lang ${vm_guest_os_language} +keyboard ${vm_guest_os_keyboard} +timezone ${vm_guest_os_timezone} rootpw --lock user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel cdrom diff --git a/builds/linux/centos-stream-8/variables.auto.pkrvars.hcl b/builds/linux/centos-stream-8/linux-centos-stream.auto.pkrvars.hcl similarity index 79% rename from builds/linux/centos-stream-8/variables.auto.pkrvars.hcl rename to builds/linux/centos-stream-8/linux-centos-stream.auto.pkrvars.hcl index 2fc9640c3..f80a093c6 100644 --- a/builds/linux/centos-stream-8/variables.auto.pkrvars.hcl +++ b/builds/linux/centos-stream-8/linux-centos-stream.auto.pkrvars.hcl @@ -4,10 +4,13 @@ */ // Guest Operating System Metadata -vm_guest_os_family = "linux" -vm_guest_os_vendor = "centos-stream" -vm_guest_os_member = "server" -vm_guest_os_version = "8" +vm_guest_os_language = "en_US" +vm_guest_os_keyboard = "us" +vm_guest_os_timezone = "UTC" +vm_guest_os_family = "linux" +vm_guest_os_vendor = "centos-stream" +vm_guest_os_member = "server" +vm_guest_os_version = "8" // Virtual Machine Guest Operating System Setting vm_guest_os_type = "centos8_64Guest" @@ -30,8 +33,8 @@ iso_file = "iso-linux-centos-stream-8.iso" iso_checksum = "552cf5dcdc9d3db41791a2b3bbbd18335d75607ca54e7aa8bf28a6ea1d49ce914a55da0bd839123aa96654b7de6db65cc786beb71e6233982ea96ce456a47035" // Boot Settings -vm_boot_order = "disk,cdrom" -vm_boot_wait = "2s" +vm_boot_order = "disk,cdrom" +vm_boot_wait = "2s" // Communicator Settings communicator_port = 22 diff --git a/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl b/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl new file mode 100644 index 000000000..b44abbc3e --- /dev/null +++ b/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl @@ -0,0 +1,126 @@ +/* + DESCRIPTION: + CentOS Stream 8 template using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.7.4" + required_plugins { + vsphere = { + version = ">= v1.0.1" + source = "github.com/hashicorp/vsphere" + } + } +} + +// BLOCK: locals +// Defines the local variables. + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "vsphere-iso" "linux-centos-stream" { + + // vCenter Server Endpoint Settings and Credentials + vcenter_server = var.vsphere_endpoint + username = var.vsphere_username + password = var.vsphere_password + insecure_connection = var.vsphere_insecure_connection + + // vSphere Settings + datacenter = var.vsphere_datacenter + cluster = var.vsphere_cluster + datastore = var.vsphere_datastore + folder = var.vsphere_folder + + // Virtual Machine Settings + guest_os_type = var.vm_guest_os_type + vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" + firmware = var.vm_firmware + CPUs = var.vm_cpu_sockets + cpu_cores = var.vm_cpu_cores + CPU_hot_plug = var.vm_cpu_hot_add + RAM = var.vm_mem_size + RAM_hot_plug = var.vm_mem_hot_add + cdrom_type = var.vm_cdrom_type + disk_controller_type = var.vm_disk_controller_type + storage { + disk_size = var.vm_disk_size + disk_thin_provisioned = var.vm_disk_thin_provisioned + } + network_adapters { + network = var.vsphere_network + network_card = var.vm_network_card + } + vm_version = var.common_vm_version + remove_cdrom = var.common_remove_cdrom + tools_upgrade_policy = var.common_tools_upgrade_policy + notes = "Built by HashiCorp Packer on ${local.buildtime}." + + // Removable Media Settings + iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + http_content = { + "/ks.cfg" = templatefile("${path.cwd}/http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted, vm_guest_os_language = var.vm_guest_os_language, vm_guest_os_keyboard = var.vm_guest_os_keyboard, vm_guest_os_timezone = var.vm_guest_os_timezone }) + } + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = ["up", "e", "", "text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "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 + + // Communicator Settings and Credentials + communicator = "ssh" + ssh_username = var.build_username + ssh_password = var.build_password + ssh_port = var.communicator_port + ssh_timeout = var.communicator_timeout + + // Template and Content Library Settings + convert_to_template = var.common_template_conversion + content_library_destination { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } +} + +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = ["source.vsphere-iso.linux-centos-stream"] + + provisioner "file" { + destination = "/tmp/root-ca.crt" + source = "../../../certificates/root-ca.crt" + } + + provisioner "shell" { + execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" + environment_vars = [ + "BUILD_USERNAME=${var.build_username}", + "BUILD_KEY=${var.build_key}", + "ANSIBLE_USERNAME=${var.ansible_username}", + "ANSIBLE_KEY=${var.ansible_key}" + ] + scripts = var.scripts + } + + post-processor "manifest" { + output = "${path.cwd}/output/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + strip_path = false + } +} diff --git a/builds/linux/centos-stream-8/output/.placeholder b/builds/linux/centos-stream-8/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/linux/centos-stream-8/centos-stream-8.pkr.hcl b/builds/linux/centos-stream-8/variables.pkr.hcl similarity index 62% rename from builds/linux/centos-stream-8/centos-stream-8.pkr.hcl rename to builds/linux/centos-stream-8/variables.pkr.hcl index 6deaa60c7..98a6f4c49 100644 --- a/builds/linux/centos-stream-8/centos-stream-8.pkr.hcl +++ b/builds/linux/centos-stream-8/variables.pkr.hcl @@ -1,21 +1,8 @@ /* DESCRIPTION: - CentOS Stream 8 template using the Packer Builder for VMware vSphere (vsphere-iso). + CentOS Stream 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ -// BLOCK: packer -// The Packer configuration. - -packer { - required_version = ">= 1.7.4" - required_plugins { - vsphere = { - version = ">= v1.0.1" - source = "github.com/hashicorp/vsphere" - } - } -} - // BLOCK: variable // Defines the input variables. @@ -68,19 +55,37 @@ variable "vsphere_network" { variable "vsphere_folder" { type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" } // Virtual Machine Settings +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en_US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "us" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + variable "vm_guest_os_family" { type = string - description = "The guest operating system family. Used for naming. (e.g.'linux')" + description = "The guest operating system family. Used for naming and VMware tools. (e.g.'linux')" } variable "vm_guest_os_vendor" { type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'centos-stream')" + description = "The guest operating system vendor. Used for naming . (e.g. 'centos-stream')" } variable "vm_guest_os_member" { @@ -100,7 +105,7 @@ variable "vm_guest_os_type" { variable "vm_firmware" { type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" default = "efi-secure" } @@ -216,7 +221,7 @@ variable "common_iso_path" { variable "common_iso_hash" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" } variable "iso_file" { @@ -243,13 +248,13 @@ variable "common_http_port_max" { variable "vm_boot_order" { type = string - description = "The time to wait before boot." + description = "The boot order for virtual machines devices." default = "disk,cdrom" } variable "vm_boot_wait" { type = string - description = "The boot order for virtual machines devices." + description = "The time to wait before boot." } variable "common_ip_wait_timeout" { @@ -278,13 +283,13 @@ variable "build_password" { variable "build_password_encrypted" { type = string - description = "The encrypted password for building the guest operating system." + description = "The encrypted password to login to the guest operating system." sensitive = true } variable "build_key" { type = string - description = "The key to login to the guest operating system." + description = "The public key to login to the guest operating system." sensitive = true } @@ -308,7 +313,7 @@ variable "ansible_username" { variable "ansible_key" { type = string - description = "The key for Ansible to login to the guest operating system." + description = "The public key for Ansible to login to the guest operating system." sensitive = true } @@ -324,113 +329,4 @@ variable "inline" { type = list(string) description = "A list of commands to execute." default = [] -} - -// BLOCK: locals -// Defines the local variables. - -locals { - buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) -} - -// BLOCK: source -// Defines the builder configuration blocks. - -source "vsphere-iso" "linux-centos-stream" { - - // vCenter Server Endpoint Settings and Credentials - vcenter_server = var.vsphere_endpoint - username = var.vsphere_username - password = var.vsphere_password - insecure_connection = var.vsphere_insecure_connection - - // vSphere Settings - datacenter = var.vsphere_datacenter - cluster = var.vsphere_cluster - datastore = var.vsphere_datastore - folder = var.vsphere_folder - - // Virtual Machine Settings - guest_os_type = var.vm_guest_os_type - vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" - firmware = var.vm_firmware - CPUs = var.vm_cpu_sockets - cpu_cores = var.vm_cpu_cores - CPU_hot_plug = var.vm_cpu_hot_add - RAM = var.vm_mem_size - RAM_hot_plug = var.vm_mem_hot_add - cdrom_type = var.vm_cdrom_type - disk_controller_type = var.vm_disk_controller_type - storage { - disk_size = var.vm_disk_size - disk_thin_provisioned = var.vm_disk_thin_provisioned - } - network_adapters { - network = var.vsphere_network - network_card = var.vm_network_card - } - vm_version = var.common_vm_version - remove_cdrom = var.common_remove_cdrom - tools_upgrade_policy = var.common_tools_upgrade_policy - notes = "Built by HashiCorp Packer on ${local.buildtime}." - - // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" - - // Boot and Provisioning Settings - http_port_min = var.common_http_port_min - http_port_max = var.common_http_port_max - http_content = { - "/ks.cfg" = templatefile("http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted }) - } - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["up", "e", "", "text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "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 - - // Communicator Settings and Credentials - communicator = "ssh" - ssh_username = var.build_username - ssh_password = var.build_password - ssh_port = var.communicator_port - ssh_timeout = var.communicator_timeout - - // Template and Content Library Settings - convert_to_template = var.common_template_conversion - content_library_destination { - library = var.common_content_library_name - ovf = var.common_content_library_ovf - destroy = var.common_content_library_destroy - } -} - -// BLOCK: build -// Defines the builders to run, provisioners, and post-processors. - -build { - sources = ["source.vsphere-iso.linux-centos-stream"] - - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "../../../certificates/root-ca.crt" - } - - provisioner "shell" { - execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" - environment_vars = [ - "BUILD_USERNAME=${var.build_username}", - "BUILD_KEY=${var.build_key}", - "ANSIBLE_USERNAME=${var.ansible_username}", - "ANSIBLE_KEY=${var.ansible_key}" - ] - scripts = var.scripts - } - - post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" - strip_path = false - } -} +} \ No newline at end of file diff --git a/builds/linux/photon-4/http/ks.pkrtpl.hcl b/builds/linux/photon-4/http/ks.pkrtpl.hcl index 7119950ad..8bc885762 100644 --- a/builds/linux/photon-4/http/ks.pkrtpl.hcl +++ b/builds/linux/photon-4/http/ks.pkrtpl.hcl @@ -1,5 +1,5 @@ { - "hostname": "photon-server", + "hostname": "photon", "password": { "crypted": true, @@ -9,16 +9,24 @@ "bootmode": "bios", "packagelist_file": "packages_minimal.json", "additional_packages": [ - "sudo" + "sudo", + "vim", + "cloud-utils" ], "postinstall": [ "#!/bin/sh", + "useradd -m -p '${build_password_encrypted}' -s /bin/bash ${build_username}", + "usermod -aG sudo ${build_username}", + "chage -I -1 -m 0 -M 99999 -E -1 root", + "chage -I -1 -m 0 -M 99999 -E -1 ${build_username}", + "iptables -A INPUT -p tcp --dport 22 -j ACCEPT", + "iptables -A INPUT -p ICMP -j ACCEPT", + "iptables -A OUTPUT -p ICMP -j ACCEPT", + "iptables-save > /etc/systemd/scripts/ip4save", + "systemctl restart iptables", "sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config", "sed -i 's/MaxAuthTries.*/MaxAuthTries 10/g' /etc/ssh/sshd_config", - "systemctl restart sshd.service", - "chage -I -1 -m 0 -M 99999 -E -1 root", - "useradd -m -p '${build_password_encrypted}' -s /bin/bash ${build_username}", - "usermod -aG sudo ${build_username}" + "systemctl restart sshd.service" ], "install_linux_esx": true, "network": { diff --git a/builds/linux/photon-4/variables.auto.pkrvars.hcl b/builds/linux/photon-4/linux-photon.auto.pkrvars.hcl similarity index 95% rename from builds/linux/photon-4/variables.auto.pkrvars.hcl rename to builds/linux/photon-4/linux-photon.auto.pkrvars.hcl index 9401d59c9..f4f543d46 100644 --- a/builds/linux/photon-4/variables.auto.pkrvars.hcl +++ b/builds/linux/photon-4/linux-photon.auto.pkrvars.hcl @@ -30,8 +30,8 @@ iso_file = "iso-linux-photon-4.iso" iso_checksum = "9cb0ae0329a50733f56e921c1e220ce3e9d328499890b8202e05991daec34c4184ef03606caf706e9058035115c23fef1cacbb184200fca8ec577a191ad3f394" // Boot Settings -vm_boot_order = "disk,cdrom" -vm_boot_wait = "2s" +vm_boot_order = "disk,cdrom" +vm_boot_wait = "2s" // Communicator Settings communicator_port = 22 diff --git a/builds/linux/photon-4/linux-photon.pkr.hcl b/builds/linux/photon-4/linux-photon.pkr.hcl new file mode 100644 index 000000000..307501cc5 --- /dev/null +++ b/builds/linux/photon-4/linux-photon.pkr.hcl @@ -0,0 +1,127 @@ +/* + DESCRIPTION: + VMware Photon OS 4 template using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.7.4" + required_plugins { + vsphere = { + version = ">= v1.0.1" + source = "github.com/hashicorp/vsphere" + } + } +} + +// BLOCK: locals +// Defines the local variables. + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "vsphere-iso" "linux-photon" { + + // vCenter Server Endpoint Settings and Credentials + vcenter_server = var.vsphere_endpoint + username = var.vsphere_username + password = var.vsphere_password + insecure_connection = var.vsphere_insecure_connection + + // vSphere Settings + datacenter = var.vsphere_datacenter + cluster = var.vsphere_cluster + datastore = var.vsphere_datastore + folder = var.vsphere_folder + + // Virtual Machine Settings + guest_os_type = var.vm_guest_os_type + vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" + firmware = var.vm_firmware + CPUs = var.vm_cpu_sockets + cpu_cores = var.vm_cpu_cores + CPU_hot_plug = var.vm_cpu_hot_add + RAM = var.vm_mem_size + RAM_hot_plug = var.vm_mem_hot_add + cdrom_type = var.vm_cdrom_type + disk_controller_type = var.vm_disk_controller_type + storage { + disk_size = var.vm_disk_size + disk_thin_provisioned = var.vm_disk_thin_provisioned + } + network_adapters { + network = var.vsphere_network + network_card = var.vm_network_card + } + vm_version = var.common_vm_version + remove_cdrom = var.common_remove_cdrom + tools_upgrade_policy = var.common_tools_upgrade_policy + notes = "Built by HashiCorp Packer on ${local.buildtime}." + + // Removable Media Settings + iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + http_content = { + "/ks.json" = templatefile("http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted }) + "/packages.json" = file("http/packages_minimal.json") + } + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [" vmlinuz initrd=initrd.img root=/dev/ram0 loglevel=3 insecure_installation=1 ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.json photon.media=cdrom "] + ip_wait_timeout = var.common_ip_wait_timeout + shutdown_command = "echo '${var.build_password}' | sudo -S -E shutdown -P now" + shutdown_timeout = var.common_shutdown_timeout + + // Communicator Settings and Credentials + communicator = "ssh" + ssh_username = var.build_username + ssh_password = var.build_password + ssh_port = var.communicator_port + ssh_timeout = var.communicator_timeout + + // Template and Content Library Settings + convert_to_template = var.common_template_conversion + content_library_destination { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } +} + +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = ["source.vsphere-iso.linux-photon"] + + provisioner "file" { + destination = "/tmp/root-ca.crt" + source = "../../../certificates/root-ca.crt" + } + + provisioner "shell" { + execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" + environment_vars = [ + "BUILD_USERNAME=${var.build_username}", + "BUILD_KEY=${var.build_key}", + "ANSIBLE_USERNAME=${var.ansible_username}", + "ANSIBLE_KEY=${var.ansible_key}" + ] + scripts = var.scripts + } + + post-processor "manifest" { + output = "${path.cwd}/output/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + strip_path = false + } +} diff --git a/builds/linux/photon-4/output/.placeholder b/builds/linux/photon-4/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/linux/photon-4/photon-4.pkr.hcl b/builds/linux/photon-4/variables.pkr.hcl similarity index 61% rename from builds/linux/photon-4/photon-4.pkr.hcl rename to builds/linux/photon-4/variables.pkr.hcl index 165704464..59bed1388 100644 --- a/builds/linux/photon-4/photon-4.pkr.hcl +++ b/builds/linux/photon-4/variables.pkr.hcl @@ -1,21 +1,8 @@ /* DESCRIPTION: - VMware Photon OS 4 template using the Packer Builder for VMware vSphere (vsphere-iso). + VMware Photon OS 4 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ -// BLOCK: packer -// The Packer configuration. - -packer { - required_version = ">= 1.7.4" - required_plugins { - vsphere = { - version = ">= v1.0.1" - source = "github.com/hashicorp/vsphere" - } - } -} - // BLOCK: variable // Defines the input variables. @@ -68,19 +55,19 @@ variable "vsphere_network" { variable "vsphere_folder" { type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" } // Virtual Machine Settings variable "vm_guest_os_family" { type = string - description = "The guest operating system family. Used for naming. (e.g.'linux')" + description = "The guest operating system family. Used for naming and VMware tools. (e.g.'linux')" } variable "vm_guest_os_vendor" { type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'photon')" + description = "The guest operating system vendor. Used for naming . (e.g. 'photon')" } variable "vm_guest_os_member" { @@ -100,7 +87,7 @@ variable "vm_guest_os_type" { variable "vm_firmware" { type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" default = "efi-secure" } @@ -216,7 +203,7 @@ variable "common_iso_path" { variable "common_iso_hash" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" } variable "iso_file" { @@ -243,13 +230,13 @@ variable "common_http_port_max" { variable "vm_boot_order" { type = string - description = "The time to wait before boot." + description = "The boot order for virtual machines devices." default = "disk,cdrom" } variable "vm_boot_wait" { type = string - description = "The boot order for virtual machines devices." + description = "The time to wait before boot." } variable "common_ip_wait_timeout" { @@ -278,13 +265,13 @@ variable "build_password" { variable "build_password_encrypted" { type = string - description = "The encrypted password for building the guest operating system." + description = "The encrypted password to login to the guest operating system." sensitive = true } variable "build_key" { type = string - description = "The key to login to the guest operating system." + description = "The public key to login to the guest operating system." sensitive = true } @@ -308,7 +295,7 @@ variable "ansible_username" { variable "ansible_key" { type = string - description = "The key for Ansible to login to the guest operating system." + description = "The public key for Ansible to login to the guest operating system." sensitive = true } @@ -324,114 +311,4 @@ variable "inline" { type = list(string) description = "A list of commands to execute." default = [] -} - -// BLOCK: locals -// Defines the local variables. - -locals { - buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) -} - -// BLOCK: source -// Defines the builder configuration blocks. - -source "vsphere-iso" "linux-photon" { - - // vCenter Server Endpoint Settings and Credentials - vcenter_server = var.vsphere_endpoint - username = var.vsphere_username - password = var.vsphere_password - insecure_connection = var.vsphere_insecure_connection - - // vSphere Settings - datacenter = var.vsphere_datacenter - cluster = var.vsphere_cluster - datastore = var.vsphere_datastore - folder = var.vsphere_folder - - // Virtual Machine Settings - guest_os_type = var.vm_guest_os_type - vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" - firmware = var.vm_firmware - CPUs = var.vm_cpu_sockets - cpu_cores = var.vm_cpu_cores - CPU_hot_plug = var.vm_cpu_hot_add - RAM = var.vm_mem_size - RAM_hot_plug = var.vm_mem_hot_add - cdrom_type = var.vm_cdrom_type - disk_controller_type = var.vm_disk_controller_type - storage { - disk_size = var.vm_disk_size - disk_thin_provisioned = var.vm_disk_thin_provisioned - } - network_adapters { - network = var.vsphere_network - network_card = var.vm_network_card - } - vm_version = var.common_vm_version - remove_cdrom = var.common_remove_cdrom - tools_upgrade_policy = var.common_tools_upgrade_policy - notes = "Built by HashiCorp Packer on ${local.buildtime}." - - // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" - - // Boot and Provisioning Settings - http_port_min = var.common_http_port_min - http_port_max = var.common_http_port_max - http_content = { - "/ks.json" = templatefile("http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted }) - "/packages.json" = file("http/packages_minimal.json") - } - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = [" vmlinuz initrd=initrd.img root=/dev/ram0 loglevel=3 insecure_installation=1 ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.json photon.media=cdrom "] - ip_wait_timeout = var.common_ip_wait_timeout - shutdown_command = "echo '${var.build_password}' | sudo -S -E shutdown -P now" - shutdown_timeout = var.common_shutdown_timeout - - // Communicator Settings and Credentials - communicator = "ssh" - ssh_username = var.build_username - ssh_password = var.build_password - ssh_port = var.communicator_port - ssh_timeout = var.communicator_timeout - - // Template and Content Library Settings - convert_to_template = var.common_template_conversion - content_library_destination { - library = var.common_content_library_name - ovf = var.common_content_library_ovf - destroy = var.common_content_library_destroy - } -} - -// BLOCK: build -// Defines the builders to run, provisioners, and post-processors. - -build { - sources = ["source.vsphere-iso.linux-photon"] - - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "../../../certificates/root-ca.crt" - } - - provisioner "shell" { - execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" - environment_vars = [ - "BUILD_USERNAME=${var.build_username}", - "BUILD_KEY=${var.build_key}", - "ANSIBLE_USERNAME=${var.ansible_username}", - "ANSIBLE_KEY=${var.ansible_key}" - ] - scripts = var.scripts - } - - post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" - strip_path = false - } -} +} \ No newline at end of file diff --git a/builds/linux/redhat-linux-8/http/ks.pkrtpl.hcl b/builds/linux/redhat-linux-8/http/ks.pkrtpl.hcl index 47327cbcf..4d910310a 100644 --- a/builds/linux/redhat-linux-8/http/ks.pkrtpl.hcl +++ b/builds/linux/redhat-linux-8/http/ks.pkrtpl.hcl @@ -1,9 +1,9 @@ # Red Hat Enterprise Linux Server 8 install eula --agreed -lang en_US -keyboard us -timezone UTC +lang ${vm_guest_os_language} +keyboard ${vm_guest_os_keyboard} +timezone ${vm_guest_os_timezone} rootpw --lock user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel cdrom diff --git a/builds/linux/redhat-linux-8/variables.auto.pkrvars.hcl b/builds/linux/redhat-linux-8/linux-redhat-linux.auto.pkrvars.hcl similarity index 79% rename from builds/linux/redhat-linux-8/variables.auto.pkrvars.hcl rename to builds/linux/redhat-linux-8/linux-redhat-linux.auto.pkrvars.hcl index 5d16b2c84..97a4b5202 100644 --- a/builds/linux/redhat-linux-8/variables.auto.pkrvars.hcl +++ b/builds/linux/redhat-linux-8/linux-redhat-linux.auto.pkrvars.hcl @@ -4,10 +4,13 @@ */ // Guest Operating System Metadata -vm_guest_os_family = "linux" -vm_guest_os_vendor = "redhat-linux" -vm_guest_os_member = "server" -vm_guest_os_version = "8" +vm_guest_os_language = "en_US" +vm_guest_os_keyboard = "us" +vm_guest_os_timezone = "UTC" +vm_guest_os_family = "linux" +vm_guest_os_vendor = "redhat-linux" +vm_guest_os_member = "server" +vm_guest_os_version = "8" // Virtual Machine Guest Operating System Setting vm_guest_os_type = "rhel8_64Guest" @@ -30,8 +33,8 @@ iso_file = "iso-linux-redhat-linux-8.iso" iso_checksum = "3b3f4ad5a0b8ef289643bf8cb7f6f5a0fa7b2cbca747dc0ed6b588f574f38bee8c741b76519b8d0bf7dd4328d9ecc950bad443c22ddc8347837a4c58cd85b3a7" // Boot Settings -vm_boot_order = "disk,cdrom" -vm_boot_wait = "2s" +vm_boot_order = "disk,cdrom" +vm_boot_wait = "2s" // Communicator Settings communicator_port = 22 diff --git a/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl b/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl new file mode 100644 index 000000000..94532fe78 --- /dev/null +++ b/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl @@ -0,0 +1,128 @@ +/* + DESCRIPTION: + Red Hat Enterprise Linux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.7.4" + required_plugins { + vsphere = { + version = ">= v1.0.1" + source = "github.com/hashicorp/vsphere" + } + } +} + +// BLOCK: locals +// Defines the local variables. + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "vsphere-iso" "linux-redhat-linux" { + + // vCenter Server Endpoint Settings and Credentials + vcenter_server = var.vsphere_endpoint + username = var.vsphere_username + password = var.vsphere_password + insecure_connection = var.vsphere_insecure_connection + + // vSphere Settings + datacenter = var.vsphere_datacenter + cluster = var.vsphere_cluster + datastore = var.vsphere_datastore + folder = var.vsphere_folder + + // Virtual Machine Settings + guest_os_type = var.vm_guest_os_type + vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" + firmware = var.vm_firmware + CPUs = var.vm_cpu_sockets + cpu_cores = var.vm_cpu_cores + CPU_hot_plug = var.vm_cpu_hot_add + RAM = var.vm_mem_size + RAM_hot_plug = var.vm_mem_hot_add + cdrom_type = var.vm_cdrom_type + disk_controller_type = var.vm_disk_controller_type + storage { + disk_size = var.vm_disk_size + disk_thin_provisioned = var.vm_disk_thin_provisioned + } + network_adapters { + network = var.vsphere_network + network_card = var.vm_network_card + } + vm_version = var.common_vm_version + remove_cdrom = var.common_remove_cdrom + tools_upgrade_policy = var.common_tools_upgrade_policy + notes = "Built by HashiCorp Packer on ${local.buildtime}." + + // Removable Media Settings + iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + http_content = { + "/ks.cfg" = templatefile("${path.cwd}/http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted, vm_guest_os_language = var.vm_guest_os_language, vm_guest_os_keyboard = var.vm_guest_os_keyboard, vm_guest_os_timezone = var.vm_guest_os_timezone }) + } + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = ["up", "e", "", "text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "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 + + // Communicator Settings and Credentials + communicator = "ssh" + ssh_username = var.build_username + ssh_password = var.build_password + ssh_port = var.communicator_port + ssh_timeout = var.communicator_timeout + + // Template and Content Library Settings + convert_to_template = var.common_template_conversion + content_library_destination { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } +} + +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = ["source.vsphere-iso.linux-redhat-linux"] + + provisioner "file" { + destination = "/tmp/root-ca.crt" + source = "../../../certificates/root-ca.crt" + } + + provisioner "shell" { + execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" + environment_vars = [ + "BUILD_USERNAME=${var.build_username}", + "BUILD_KEY=${var.build_key}", + "ANSIBLE_USERNAME=${var.ansible_username}", + "ANSIBLE_KEY=${var.ansible_key}", + "RHSM_USERNAME=${var.rhsm_username}", + "RHSM_PASSWORD=${var.rhsm_password}" + ] + scripts = var.scripts + } + + post-processor "manifest" { + output = "${path.cwd}/output/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + strip_path = false + } +} diff --git a/builds/linux/redhat-linux-8/output/.placeholder b/builds/linux/redhat-linux-8/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/linux/redhat-linux-8/redhat-linux-8.pkr.hcl b/builds/linux/redhat-linux-8/variables.pkr.hcl similarity index 62% rename from builds/linux/redhat-linux-8/redhat-linux-8.pkr.hcl rename to builds/linux/redhat-linux-8/variables.pkr.hcl index 9c7fbc290..30dda6cf1 100644 --- a/builds/linux/redhat-linux-8/redhat-linux-8.pkr.hcl +++ b/builds/linux/redhat-linux-8/variables.pkr.hcl @@ -1,21 +1,8 @@ /* DESCRIPTION: - Red Hat Enterprise Linux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). + Red Hat Enterprise Linux 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ -// BLOCK: packer -// The Packer configuration. - -packer { - required_version = ">= 1.7.4" - required_plugins { - vsphere = { - version = ">= v1.0.1" - source = "github.com/hashicorp/vsphere" - } - } -} - // BLOCK: variable // Defines the input variables. @@ -82,19 +69,37 @@ variable "vsphere_network" { variable "vsphere_folder" { type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" } // Virtual Machine Settings +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en_US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "us" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + variable "vm_guest_os_family" { type = string - description = "The guest operating system family. Used for naming. (e.g.'linux')" + description = "The guest operating system family. Used for naming and VMware tools. (e.g.'linux')" } variable "vm_guest_os_vendor" { type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'redhat-linux')" + description = "The guest operating system vendor. Used for naming . (e.g. 'redhat-linux')" } variable "vm_guest_os_member" { @@ -114,7 +119,7 @@ variable "vm_guest_os_type" { variable "vm_firmware" { type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" default = "efi-secure" } @@ -230,7 +235,7 @@ variable "common_iso_path" { variable "common_iso_hash" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" } variable "iso_file" { @@ -257,13 +262,13 @@ variable "common_http_port_max" { variable "vm_boot_order" { type = string - description = "The time to wait before boot." + description = "The boot order for virtual machines devices." default = "disk,cdrom" } variable "vm_boot_wait" { type = string - description = "The boot order for virtual machines devices." + description = "The time to wait before boot." } variable "common_ip_wait_timeout" { @@ -292,13 +297,13 @@ variable "build_password" { variable "build_password_encrypted" { type = string - description = "The encrypted password for building the guest operating system." + description = "The encrypted password to login to the guest operating system." sensitive = true } variable "build_key" { type = string - description = "The key to login to the guest operating system." + description = "The public key to login to the guest operating system." sensitive = true } @@ -322,7 +327,7 @@ variable "ansible_username" { variable "ansible_key" { type = string - description = "The key for Ansible to login to the guest operating system." + description = "The public key for Ansible to login to the guest operating system." sensitive = true } @@ -338,115 +343,4 @@ variable "inline" { type = list(string) description = "A list of commands to execute." default = [] -} - -// BLOCK: locals -// Defines the local variables. - -locals { - buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) -} - -// BLOCK: source -// Defines the builder configuration blocks. - -source "vsphere-iso" "linux-redhat-linux" { - - // vCenter Server Endpoint Settings and Credentials - vcenter_server = var.vsphere_endpoint - username = var.vsphere_username - password = var.vsphere_password - insecure_connection = var.vsphere_insecure_connection - - // vSphere Settings - datacenter = var.vsphere_datacenter - cluster = var.vsphere_cluster - datastore = var.vsphere_datastore - folder = var.vsphere_folder - - // Virtual Machine Settings - guest_os_type = var.vm_guest_os_type - vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" - firmware = var.vm_firmware - CPUs = var.vm_cpu_sockets - cpu_cores = var.vm_cpu_cores - CPU_hot_plug = var.vm_cpu_hot_add - RAM = var.vm_mem_size - RAM_hot_plug = var.vm_mem_hot_add - cdrom_type = var.vm_cdrom_type - disk_controller_type = var.vm_disk_controller_type - storage { - disk_size = var.vm_disk_size - disk_thin_provisioned = var.vm_disk_thin_provisioned - } - network_adapters { - network = var.vsphere_network - network_card = var.vm_network_card - } - vm_version = var.common_vm_version - remove_cdrom = var.common_remove_cdrom - tools_upgrade_policy = var.common_tools_upgrade_policy - notes = "Built by HashiCorp Packer on ${local.buildtime}." - - // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" - - // Boot and Provisioning Settings - http_port_min = var.common_http_port_min - http_port_max = var.common_http_port_max - http_content = { - "/ks.cfg" = templatefile("http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted }) - } - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["up", "e", "", "text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "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 - - // Communicator Settings and Credentials - communicator = "ssh" - ssh_username = var.build_username - ssh_password = var.build_password - ssh_port = var.communicator_port - ssh_timeout = var.communicator_timeout - - // Template and Content Library Settings - convert_to_template = var.common_template_conversion - content_library_destination { - library = var.common_content_library_name - ovf = var.common_content_library_ovf - destroy = var.common_content_library_destroy - } -} - -// BLOCK: build -// Defines the builders to run, provisioners, and post-processors. - -build { - sources = ["source.vsphere-iso.linux-redhat-linux"] - - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "../../../certificates/root-ca.crt" - } - - provisioner "shell" { - execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" - environment_vars = [ - "BUILD_USERNAME=${var.build_username}", - "BUILD_KEY=${var.build_key}", - "ANSIBLE_USERNAME=${var.ansible_username}", - "ANSIBLE_KEY=${var.ansible_key}", - "RHSM_USERNAME=${var.rhsm_username}", - "RHSM_PASSWORD=${var.rhsm_password}" - ] - scripts = var.scripts - } - - post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" - strip_path = false - } -} +} \ No newline at end of file diff --git a/builds/linux/rocky-linux-8/http/ks.pkrtpl.hcl b/builds/linux/rocky-linux-8/http/ks.pkrtpl.hcl index 9fcf977bd..722297c37 100644 --- a/builds/linux/rocky-linux-8/http/ks.pkrtpl.hcl +++ b/builds/linux/rocky-linux-8/http/ks.pkrtpl.hcl @@ -1,9 +1,9 @@ # Rocky Linux 8 install eula --agreed -lang en_US -keyboard us -timezone UTC +lang ${vm_guest_os_language} +keyboard ${vm_guest_os_keyboard} +timezone ${vm_guest_os_timezone} rootpw --lock user --name=${build_username} --iscrypted --password=${build_password_encrypted} --groups=wheel cdrom diff --git a/builds/linux/rocky-linux-8/variables.auto.pkrvars.hcl b/builds/linux/rocky-linux-8/linux-rocky-linux.auto.pkrvars.hcl similarity index 77% rename from builds/linux/rocky-linux-8/variables.auto.pkrvars.hcl rename to builds/linux/rocky-linux-8/linux-rocky-linux.auto.pkrvars.hcl index 928e4d149..fecb6e9e0 100644 --- a/builds/linux/rocky-linux-8/variables.auto.pkrvars.hcl +++ b/builds/linux/rocky-linux-8/linux-rocky-linux.auto.pkrvars.hcl @@ -4,16 +4,19 @@ */ // Guest Operating System Metadata -vm_guest_os_family = "linux" -vm_guest_os_vendor = "rocky-linux" -vm_guest_os_member = "server" -vm_guest_os_version = "8" +vm_guest_os_language = "en_US" +vm_guest_os_keyboard = "us" +vm_guest_os_timezone = "UTC" +vm_guest_os_family = "linux" +vm_guest_os_vendor = "rocky-linux" +vm_guest_os_member = "server" +vm_guest_os_version = "8" // Virtual Machine Guest Operating System Setting vm_guest_os_type = "centos8_64Guest" // Virtual Machine Hardware Settings -vm_firmware = "bios" +vm_firmware = "efi" vm_cdrom_type = "sata" vm_cpu_sockets = 2 vm_cpu_cores = 1 @@ -30,8 +33,8 @@ iso_file = "iso-linux-rocky-linux-8.iso" iso_checksum = "dbfacdbbfd50059a0dda5c19071bc2f55496f3651279eafa6f50d2ea2d941fdd8b43b8710e2187cdbfe630fa7efb5d3b047ee0cdbc2f8d09bd5f68a7014e0d0c" // Boot Settings -vm_boot_order = "disk,cdrom" -vm_boot_wait = "2s" +vm_boot_order = "disk,cdrom" +vm_boot_wait = "2s" // Communicator Settings communicator_port = 22 diff --git a/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl b/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl new file mode 100644 index 000000000..38cb99eab --- /dev/null +++ b/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl @@ -0,0 +1,126 @@ +/* + DESCRIPTION: + Rocky Linux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.7.4" + required_plugins { + vsphere = { + version = ">= v1.0.1" + source = "github.com/hashicorp/vsphere" + } + } +} + +// BLOCK: locals +// Defines the local variables. + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "vsphere-iso" "linux-rocky-linux" { + + // vCenter Server Endpoint Settings and Credentials + vcenter_server = var.vsphere_endpoint + username = var.vsphere_username + password = var.vsphere_password + insecure_connection = var.vsphere_insecure_connection + + // vSphere Settings + datacenter = var.vsphere_datacenter + cluster = var.vsphere_cluster + datastore = var.vsphere_datastore + folder = var.vsphere_folder + + // Virtual Machine Settings + guest_os_type = var.vm_guest_os_type + vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" + firmware = var.vm_firmware + CPUs = var.vm_cpu_sockets + cpu_cores = var.vm_cpu_cores + CPU_hot_plug = var.vm_cpu_hot_add + RAM = var.vm_mem_size + RAM_hot_plug = var.vm_mem_hot_add + cdrom_type = var.vm_cdrom_type + disk_controller_type = var.vm_disk_controller_type + storage { + disk_size = var.vm_disk_size + disk_thin_provisioned = var.vm_disk_thin_provisioned + } + network_adapters { + network = var.vsphere_network + network_card = var.vm_network_card + } + vm_version = var.common_vm_version + remove_cdrom = var.common_remove_cdrom + tools_upgrade_policy = var.common_tools_upgrade_policy + notes = "Built by HashiCorp Packer on ${local.buildtime}." + + // Removable Media Settings + iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + http_content = { + "/ks.cfg" = templatefile("${path.cwd}/http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted, vm_guest_os_language = var.vm_guest_os_language, vm_guest_os_keyboard = var.vm_guest_os_keyboard, vm_guest_os_timezone = var.vm_guest_os_timezone }) + } + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = ["up", "e", "", "text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", "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 + + // Communicator Settings and Credentials + communicator = "ssh" + ssh_username = var.build_username + ssh_password = var.build_password + ssh_port = var.communicator_port + ssh_timeout = var.communicator_timeout + + // Template and Content Library Settings + convert_to_template = var.common_template_conversion + content_library_destination { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } +} + +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = ["source.vsphere-iso.linux-rocky-linux"] + + provisioner "file" { + destination = "/tmp/root-ca.crt" + source = "../../../certificates/root-ca.crt" + } + + provisioner "shell" { + execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" + environment_vars = [ + "BUILD_USERNAME=${var.build_username}", + "BUILD_KEY=${var.build_key}", + "ANSIBLE_USERNAME=${var.ansible_username}", + "ANSIBLE_KEY=${var.ansible_key}" + ] + scripts = var.scripts + } + + post-processor "manifest" { + output = "${path.cwd}/output/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}.json" + strip_path = false + } +} diff --git a/builds/linux/rocky-linux-8/output/.placeholder b/builds/linux/rocky-linux-8/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/linux/rocky-linux-8/rocky-linux-8.pkr.hcl b/builds/linux/rocky-linux-8/variables.pkr.hcl similarity index 62% rename from builds/linux/rocky-linux-8/rocky-linux-8.pkr.hcl rename to builds/linux/rocky-linux-8/variables.pkr.hcl index f437c4e6d..d63648d20 100644 --- a/builds/linux/rocky-linux-8/rocky-linux-8.pkr.hcl +++ b/builds/linux/rocky-linux-8/variables.pkr.hcl @@ -1,21 +1,8 @@ /* DESCRIPTION: - Rocky Linux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). + Rocky Linux 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ -// BLOCK: packer -// The Packer configuration. - -packer { - required_version = ">= 1.7.4" - required_plugins { - vsphere = { - version = ">= v1.0.1" - source = "github.com/hashicorp/vsphere" - } - } -} - // BLOCK: variable // Defines the input variables. @@ -68,19 +55,37 @@ variable "vsphere_network" { variable "vsphere_folder" { type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" } // Virtual Machine Settings +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en_US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "us" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + variable "vm_guest_os_family" { type = string - description = "The guest operating system family. Used for naming. (e.g.'linux')" + description = "The guest operating system family. Used for naming and VMware tools. (e.g.'linux')" } variable "vm_guest_os_vendor" { type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'rocky-linux')" + description = "The guest operating system vendor. Used for naming . (e.g. 'rocky-linux')" } variable "vm_guest_os_member" { @@ -100,8 +105,8 @@ variable "vm_guest_os_type" { variable "vm_firmware" { type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" - default = "bios" + description = "The virtual machine firmware. (e.g. 'efi-secure', 'efi', or 'bios')" + default = "efi" } variable "vm_cdrom_type" { @@ -216,7 +221,7 @@ variable "common_iso_path" { variable "common_iso_hash" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" } variable "iso_file" { @@ -243,13 +248,13 @@ variable "common_http_port_max" { variable "vm_boot_order" { type = string - description = "The time to wait before boot." + description = "The boot order for virtual machines devices." default = "disk,cdrom" } variable "vm_boot_wait" { type = string - description = "The boot order for virtual machines devices." + description = "The time to wait before boot." } variable "common_ip_wait_timeout" { @@ -278,13 +283,13 @@ variable "build_password" { variable "build_password_encrypted" { type = string - description = "The encrypted password for building the guest operating system." + description = "The encrypted password to login to the guest operating system." sensitive = true } variable "build_key" { type = string - description = "The key to login to the guest operating system." + description = "The public key to login to the guest operating system." sensitive = true } @@ -308,7 +313,7 @@ variable "ansible_username" { variable "ansible_key" { type = string - description = "The key for Ansible to login to the guest operating system." + description = "The public key for Ansible to login to the guest operating system." sensitive = true } @@ -324,113 +329,4 @@ variable "inline" { type = list(string) description = "A list of commands to execute." default = [] -} - -// BLOCK: locals -// Defines the local variables. - -locals { - buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) -} - -// BLOCK: source -// Defines the builder configuration blocks. - -source "vsphere-iso" "linux-rocky-linux" { - - // vCenter Server Endpoint Settings and Credentials - vcenter_server = var.vsphere_endpoint - username = var.vsphere_username - password = var.vsphere_password - insecure_connection = var.vsphere_insecure_connection - - // vSphere Settings - datacenter = var.vsphere_datacenter - cluster = var.vsphere_cluster - datastore = var.vsphere_datastore - folder = var.vsphere_folder - - // Virtual Machine Settings - guest_os_type = var.vm_guest_os_type - vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" - firmware = var.vm_firmware - CPUs = var.vm_cpu_sockets - cpu_cores = var.vm_cpu_cores - CPU_hot_plug = var.vm_cpu_hot_add - RAM = var.vm_mem_size - RAM_hot_plug = var.vm_mem_hot_add - cdrom_type = var.vm_cdrom_type - disk_controller_type = var.vm_disk_controller_type - storage { - disk_size = var.vm_disk_size - disk_thin_provisioned = var.vm_disk_thin_provisioned - } - network_adapters { - network = var.vsphere_network - network_card = var.vm_network_card - } - vm_version = var.common_vm_version - remove_cdrom = var.common_remove_cdrom - tools_upgrade_policy = var.common_tools_upgrade_policy - notes = "Built by HashiCorp Packer on ${local.buildtime}." - - // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" - - // Boot and Provisioning Settings - http_port_min = var.common_http_port_min - http_port_max = var.common_http_port_max - http_content = { - "/ks.cfg" = templatefile("http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted }) - } - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["", "text ks=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 - - // Communicator Settings and Credentials - communicator = "ssh" - ssh_username = var.build_username - ssh_password = var.build_password - ssh_port = var.communicator_port - ssh_timeout = var.communicator_timeout - - // Template and Content Library Settings - convert_to_template = var.common_template_conversion - content_library_destination { - library = var.common_content_library_name - ovf = var.common_content_library_ovf - destroy = var.common_content_library_destroy - } -} - -// BLOCK: build -// Defines the builders to run, provisioners, and post-processors. - -build { - sources = ["source.vsphere-iso.linux-rocky-linux"] - - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "../../../certificates/root-ca.crt" - } - - provisioner "shell" { - execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" - environment_vars = [ - "BUILD_USERNAME=${var.build_username}", - "BUILD_KEY=${var.build_key}", - "ANSIBLE_USERNAME=${var.ansible_username}", - "ANSIBLE_KEY=${var.ansible_key}" - ] - scripts = var.scripts - } - - post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" - strip_path = false - } -} +} \ No newline at end of file diff --git a/builds/linux/ubuntu-server-18-04-lts/http/ks.pkrtpl.hcl b/builds/linux/ubuntu-server-18-04-lts/http/ks.pkrtpl.hcl index 1e64b366d..8acb5ba21 100644 --- a/builds/linux/ubuntu-server-18-04-lts/http/ks.pkrtpl.hcl +++ b/builds/linux/ubuntu-server-18-04-lts/http/ks.pkrtpl.hcl @@ -1,11 +1,11 @@ # Locale and Keyboard -d-i debian-installer/locale string en_US +d-i debian-installer/locale string ${vm_guest_os_language} d-i console-setup/ask_detect boolean false -d-i keyboard-configuration/xkb-keymap select us +d-i keyboard-configuration/xkb-keymap select ${vm_guest_os_keyboard} # Clock and Timezone d-i clock-setup/utc boolean true -d-i time/zone string UTC +d-i time/zone string ${vm_guest_os_timezone} # Grub and Reboot Message d-i finish-install/reboot_in_progress note diff --git a/builds/linux/ubuntu-server-18-04-lts/variables.auto.pkrvars.hcl b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.auto.pkrvars.hcl similarity index 72% rename from builds/linux/ubuntu-server-18-04-lts/variables.auto.pkrvars.hcl rename to builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.auto.pkrvars.hcl index e3db90222..7522c9268 100644 --- a/builds/linux/ubuntu-server-18-04-lts/variables.auto.pkrvars.hcl +++ b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.auto.pkrvars.hcl @@ -1,13 +1,16 @@ /* DESCRIPTION: - Ubuntu Server 18.04 LTS variables used by the Packer Plugin for VMware vSphere (vsphere-iso). + Ubuntu Server 18.04 LTS variables used by the Packer Plugin for VMware vSphere (vsphere-iso). */ // Guest Operating System Metadata -vm_guest_os_family = "linux" -vm_guest_os_vendor = "ubuntu" -vm_guest_os_member = "server" -vm_guest_os_version = "18-04-lts" +vm_guest_os_language = "en_US" +vm_guest_os_keyboard = "us" +vm_guest_os_timezone = "UTC" +vm_guest_os_family = "linux" +vm_guest_os_vendor = "ubuntu" +vm_guest_os_member = "server" +vm_guest_os_version = "18-04-lts" // Virtual Machine Guest Operating System Setting vm_guest_os_type = "ubuntu64Guest" @@ -30,8 +33,8 @@ iso_file = "iso-linux-ubuntu-server-18-04-lts.iso" iso_checksum = "43738d7dfd3e2661e4d55d2e0f9d8150f0687f4335af9b4dac047bf45fafcb4a4831685281fd5a318c5747681c351375d1129094d3f1bf38d88ab4bb49b6c457" // Boot Settings -vm_boot_order = "disk,cdrom" -vm_boot_wait = "3s" +vm_boot_order = "disk,cdrom" +vm_boot_wait = "3s" // Communicator Settings communicator_port = 22 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 new file mode 100644 index 000000000..489c77f94 --- /dev/null +++ b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl @@ -0,0 +1,139 @@ +/* + DESCRIPTION: + Ubuntu Server 18.04 LTS template using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.7.4" + required_plugins { + vsphere = { + version = ">= v1.0.1" + source = "github.com/hashicorp/vsphere" + } + } +} + +// BLOCK: locals +// Defines the local variables. + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "vsphere-iso" "linux-ubuntu-server" { + + // vCenter Server Endpoint Settings and Credentials + vcenter_server = var.vsphere_endpoint + username = var.vsphere_username + password = var.vsphere_password + insecure_connection = var.vsphere_insecure_connection + + // vSphere Settings + datacenter = var.vsphere_datacenter + cluster = var.vsphere_cluster + datastore = var.vsphere_datastore + folder = var.vsphere_folder + + // Virtual Machine Settings + guest_os_type = var.vm_guest_os_type + vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" + firmware = var.vm_firmware + CPUs = var.vm_cpu_sockets + cpu_cores = var.vm_cpu_cores + CPU_hot_plug = var.vm_cpu_hot_add + RAM = var.vm_mem_size + RAM_hot_plug = var.vm_mem_hot_add + cdrom_type = var.vm_cdrom_type + disk_controller_type = var.vm_disk_controller_type + storage { + disk_size = var.vm_disk_size + disk_thin_provisioned = var.vm_disk_thin_provisioned + } + network_adapters { + network = var.vsphere_network + network_card = var.vm_network_card + } + vm_version = var.common_vm_version + remove_cdrom = var.common_remove_cdrom + tools_upgrade_policy = var.common_tools_upgrade_policy + notes = "Built by HashiCorp Packer on ${local.buildtime}." + + // Removable Media Settings + iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + http_content = { + "/ks.cfg" = templatefile("${path.cwd}/http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted, vm_guest_os_language = var.vm_guest_os_language, vm_guest_os_keyboard = var.vm_guest_os_keyboard, vm_guest_os_timezone = var.vm_guest_os_timezone }) + } + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = ["", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "/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 + + // Communicator Settings and Credentials + communicator = "ssh" + ssh_username = var.build_username + ssh_password = var.build_password + ssh_port = var.communicator_port + ssh_timeout = var.communicator_timeout + + // Template and Content Library Settings + convert_to_template = var.common_template_conversion + content_library_destination { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } +} + +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = ["source.vsphere-iso.linux-ubuntu-server"] + + provisioner "file" { + destination = "/tmp/root-ca.crt" + source = "../../../certificates/root-ca.crt" + } + + provisioner "shell" { + execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" + environment_vars = [ + "BUILD_USERNAME=${var.build_username}", + "BUILD_KEY=${var.build_key}", + "ANSIBLE_USERNAME=${var.ansible_username}", + "ANSIBLE_KEY=${var.ansible_key}" + ] + scripts = var.scripts + } + + post-processor "manifest" { + output = "${path.cwd}/output/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}.json" + strip_path = false + } +} diff --git a/builds/linux/ubuntu-server-18-04-lts/output/.placeholder b/builds/linux/ubuntu-server-18-04-lts/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/linux/ubuntu-server-18-04-lts/ubuntu-server-18-04-lts.pkr.hcl b/builds/linux/ubuntu-server-18-04-lts/ubuntu-server-18-04-lts.pkr.hcl deleted file mode 100644 index de6d5a8a4..000000000 --- a/builds/linux/ubuntu-server-18-04-lts/ubuntu-server-18-04-lts.pkr.hcl +++ /dev/null @@ -1,449 +0,0 @@ -/* - DESCRIPTION: - Ubuntu Server 18.04 LTS template using the Packer Builder for VMware vSphere (vsphere-iso). -*/ - -// BLOCK: packer -// The Packer configuration. - -packer { - required_version = ">= 1.7.4" - required_plugins { - vsphere = { - version = ">= v1.0.1" - source = "github.com/hashicorp/vsphere" - } - } -} - -// BLOCK: variable -// Defines the input variables. - -// vSphere Credentials - -variable "vsphere_endpoint" { - type = string - description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')" -} - -variable "vsphere_username" { - type = string - description = "The username to login to the vCenter Server instance. (e.g. svc-packer-vsphere@rainpole.io)" - sensitive = true -} - -variable "vsphere_password" { - type = string - description = "The password for the login to the vCenter Server instance." - sensitive = true -} - -variable "vsphere_insecure_connection" { - type = bool - description = "Do not validate vCenter Server TLS certificate." - default = true -} - -// vSphere Settings - -variable "vsphere_datacenter" { - type = string - description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')" -} - -variable "vsphere_cluster" { - type = string - description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')" -} - -variable "vsphere_datastore" { - type = string - description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')" -} - -variable "vsphere_network" { - type = string - description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')" -} - -variable "vsphere_folder" { - type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" -} - -// Virtual Machine Settings - -variable "vm_guest_os_family" { - type = string - description = "The guest operating system family. Used for naming. (e.g.'linux')" -} - -variable "vm_guest_os_vendor" { - type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'ubuntu')" -} - -variable "vm_guest_os_member" { - type = string - description = "The guest operating system member. Used for naming. (e.g. 'server')" -} - -variable "vm_guest_os_version" { - type = string - description = "The guest operating system version. Used for naming. (e.g. '18-04-lts')" -} - -variable "vm_guest_os_type" { - type = string - description = "The guest operating system type, also know as guestid. (e.g. 'ubuntu64Guest')" -} - -variable "vm_firmware" { - type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" - default = "bios" -} - -variable "vm_cdrom_type" { - type = string - description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')" - default = "sata" -} - -variable "vm_cpu_sockets" { - type = number - description = "The number of virtual CPUs sockets. (e.g. '2')" -} - -variable "vm_cpu_cores" { - type = number - description = "The number of virtual CPUs cores per socket. (e.g. '1')" -} - -variable "vm_cpu_hot_add" { - type = bool - description = "Enable hot add CPU." - default = false -} - -variable "vm_mem_size" { - type = number - description = "The size for the virtual memory in MB. (e.g. '2048')" -} - -variable "vm_mem_hot_add" { - type = bool - description = "Enable hot add memory." - default = false -} - -variable "vm_disk_size" { - type = number - description = "The size for the virtual disk in MB. (e.g. '40960')" -} - -variable "vm_disk_controller_type" { - type = list(string) - description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')" - default = ["pvscsi"] -} - -variable "vm_disk_thin_provisioned" { - type = bool - description = "Thin provision the virtual disk." - default = true -} - -variable "vm_network_card" { - type = string - description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')" - default = "vmxnet3" -} - -variable "common_vm_version" { - type = number - description = "The vSphere virtual hardware version. (e.g. '18')" -} - -variable "common_tools_upgrade_policy" { - type = bool - description = "Upgrade VMware Tools on reboot." - default = true -} - -variable "common_remove_cdrom" { - type = bool - description = "Remove the virtual CD-ROM(s)." - default = true -} - -// Template and Content Library Settings - -variable "common_template_conversion" { - type = bool - description = "Convert the virtual machine to template. Must be 'false' for content library." - default = false -} - -variable "common_content_library_name" { - type = string - description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" -} - -variable "common_content_library_ovf" { - type = bool - description = "Export to content library as an OVF template." - default = true -} - -variable "common_content_library_destroy" { - type = bool - description = "Delete the virtual machine afer exporting to the content library." - default = true -} - -// Removable Media Settings - -variable "common_iso_datastore" { - type = string - description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" -} - -variable "common_iso_path" { - type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" -} - -variable "common_iso_hash" { - type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" -} - -variable "iso_file" { - type = string - description = "The file name of the ISO image. (e.g. 'iso-linux-ubuntu-server-18-04-lts.iso')" -} - -variable "iso_checksum" { - type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-ubuntu-server-18-04-lts.iso')" -} - -// Boot Settings - -variable "common_http_port_min" { - type = number - description = "The start of the HTTP port range." -} - -variable "common_http_port_max" { - type = number - description = "The end of the HTTP port range." -} - -variable "vm_boot_order" { - type = string - description = "The time to wait before boot." - default = "disk,cdrom" -} - -variable "vm_boot_wait" { - type = string - description = "The boot order for virtual machines devices." -} - -variable "common_ip_wait_timeout" { - type = string - description = "Time to wait for guest operating system IP address response." -} - -variable "common_shutdown_timeout" { - type = string - description = "Time to wait for guest operating system shutdown." -} - -// Communicator Settings and Credentials - -variable "build_username" { - type = string - description = "The username to login to the guest operating system. (e.g. rainpole)" - sensitive = true -} - -variable "build_password" { - type = string - description = "The password to login to the guest operating system." - sensitive = true -} - -variable "build_password_encrypted" { - type = string - description = "The encrypted password for building the guest operating system." - sensitive = true -} - -variable "build_key" { - type = string - description = "The key to login to the guest operating system." - sensitive = true -} - -variable "communicator_port" { - type = string - description = "The port for the communicator protocol." -} - -variable "communicator_timeout" { - type = string - description = "The timeout for the communicator protocol." -} - -// Ansible Credentials - -variable "ansible_username" { - type = string - description = "The username for Ansible to login to the guest operating system. (e.g. ansible)" - sensitive = true -} - -variable "ansible_key" { - type = string - description = "The key for Ansible to login to the guest operating system." - sensitive = true -} - -// Provisioner Settings - -variable "scripts" { - type = list(string) - description = "A list of scripts and their relative paths to transfer and execute." - default = [] -} - -variable "inline" { - type = list(string) - description = "A list of commands to execute." - default = [] -} - -// BLOCK: locals -// Defines the local variables. - -locals { - buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) -} - -// BLOCK: source -// Defines the builder configuration blocks. - -source "vsphere-iso" "linux-ubuntu-server" { - - // vCenter Server Endpoint Settings and Credentials - vcenter_server = var.vsphere_endpoint - username = var.vsphere_username - password = var.vsphere_password - insecure_connection = var.vsphere_insecure_connection - - // vSphere Settings - datacenter = var.vsphere_datacenter - cluster = var.vsphere_cluster - datastore = var.vsphere_datastore - folder = var.vsphere_folder - - // Virtual Machine Settings - guest_os_type = var.vm_guest_os_type - vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" - firmware = var.vm_firmware - CPUs = var.vm_cpu_sockets - cpu_cores = var.vm_cpu_cores - CPU_hot_plug = var.vm_cpu_hot_add - RAM = var.vm_mem_size - RAM_hot_plug = var.vm_mem_hot_add - cdrom_type = var.vm_cdrom_type - disk_controller_type = var.vm_disk_controller_type - storage { - disk_size = var.vm_disk_size - disk_thin_provisioned = var.vm_disk_thin_provisioned - } - network_adapters { - network = var.vsphere_network - network_card = var.vm_network_card - } - vm_version = var.common_vm_version - remove_cdrom = var.common_remove_cdrom - tools_upgrade_policy = var.common_tools_upgrade_policy - notes = "Built by HashiCorp Packer on ${local.buildtime}." - - // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" - - // Boot and Provisioning Settings - http_port_min = var.common_http_port_min - http_port_max = var.common_http_port_max - http_content = { - "/ks.cfg" = templatefile("http/ks.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted}) - } - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = ["", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "/install/vmlinuz initrd=/install/initrd.gz", - " priority=critical locale=en_US", - " 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 - - // Communicator Settings and Credentials - communicator = "ssh" - ssh_username = var.build_username - ssh_password = var.build_password - ssh_port = var.communicator_port - ssh_timeout = var.communicator_timeout - - // Template and Content Library Settings - convert_to_template = var.common_template_conversion - content_library_destination { - library = var.common_content_library_name - ovf = var.common_content_library_ovf - destroy = var.common_content_library_destroy - } -} - -// BLOCK: build -// Defines the builders to run, provisioners, and post-processors. - -build { - sources = ["source.vsphere-iso.linux-ubuntu-server"] - - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "../../../certificates/root-ca.crt" - } - - provisioner "shell" { - execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" - environment_vars = [ - "BUILD_USERNAME=${var.build_username}", - "BUILD_KEY=${var.build_key}", - "ANSIBLE_USERNAME=${var.ansible_username}", - "ANSIBLE_KEY=${var.ansible_key}" - ] - scripts = var.scripts - } - - post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" - strip_path = false - } -} diff --git a/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl b/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl new file mode 100644 index 000000000..af7d59516 --- /dev/null +++ b/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl @@ -0,0 +1,332 @@ +/* + DESCRIPTION: + Ubuntu Server 18.04 LTS variables using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: variable +// Defines the input variables. + +// vSphere Credentials + +variable "vsphere_endpoint" { + type = string + description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')" +} + +variable "vsphere_username" { + type = string + description = "The username to login to the vCenter Server instance. (e.g. svc-packer-vsphere@rainpole.io)" + sensitive = true +} + +variable "vsphere_password" { + type = string + description = "The password for the login to the vCenter Server instance." + sensitive = true +} + +variable "vsphere_insecure_connection" { + type = bool + description = "Do not validate vCenter Server TLS certificate." + default = true +} + +// vSphere Settings + +variable "vsphere_datacenter" { + type = string + description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')" +} + +variable "vsphere_cluster" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')" +} + +variable "vsphere_datastore" { + type = string + description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')" +} + +variable "vsphere_network" { + type = string + description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')" +} + +variable "vsphere_folder" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" +} + +// Virtual Machine Settings + +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en_US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "us" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + +variable "vm_guest_os_family" { + type = string + description = "The guest operating system family. Used for naming. (e.g.'linux')" +} + +variable "vm_guest_os_vendor" { + type = string + description = "The guest operating system vendor. Used for naming . (e.g. 'ubuntu')" +} + +variable "vm_guest_os_member" { + type = string + description = "The guest operating system member. Used for naming. (e.g. 'server')" +} + +variable "vm_guest_os_version" { + type = string + description = "The guest operating system version. Used for naming. (e.g. '18-04-lts')" +} + +variable "vm_guest_os_type" { + type = string + description = "The guest operating system type, also know as guestid. (e.g. 'ubuntu64Guest')" +} + +variable "vm_firmware" { + type = string + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" + default = "bios" +} + +variable "vm_cdrom_type" { + type = string + description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')" + default = "sata" +} + +variable "vm_cpu_sockets" { + type = number + description = "The number of virtual CPUs sockets. (e.g. '2')" +} + +variable "vm_cpu_cores" { + type = number + description = "The number of virtual CPUs cores per socket. (e.g. '1')" +} + +variable "vm_cpu_hot_add" { + type = bool + description = "Enable hot add CPU." + default = false +} + +variable "vm_mem_size" { + type = number + description = "The size for the virtual memory in MB. (e.g. '2048')" +} + +variable "vm_mem_hot_add" { + type = bool + description = "Enable hot add memory." + default = false +} + +variable "vm_disk_size" { + type = number + description = "The size for the virtual disk in MB. (e.g. '40960')" +} + +variable "vm_disk_controller_type" { + type = list(string) + description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')" + default = ["pvscsi"] +} + +variable "vm_disk_thin_provisioned" { + type = bool + description = "Thin provision the virtual disk." + default = true +} + +variable "vm_network_card" { + type = string + description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')" + default = "vmxnet3" +} + +variable "common_vm_version" { + type = number + description = "The vSphere virtual hardware version. (e.g. '18')" +} + +variable "common_tools_upgrade_policy" { + type = bool + description = "Upgrade VMware Tools on reboot." + default = true +} + +variable "common_remove_cdrom" { + type = bool + description = "Remove the virtual CD-ROM(s)." + default = true +} + +// Template and Content Library Settings + +variable "common_template_conversion" { + type = bool + description = "Convert the virtual machine to template. Must be 'false' for content library." + default = false +} + +variable "common_content_library_name" { + type = string + description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" +} + +variable "common_content_library_ovf" { + type = bool + description = "Export to content library as an OVF template." + default = true +} + +variable "common_content_library_destroy" { + type = bool + description = "Delete the virtual machine afer exporting to the content library." + default = true +} + +// Removable Media Settings + +variable "common_iso_datastore" { + type = string + description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" +} + +variable "common_iso_path" { + type = string + description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" +} + +variable "common_iso_hash" { + type = string + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" +} + +variable "iso_file" { + type = string + description = "The file name of the ISO image. (e.g. 'iso-linux-ubuntu-server-18-04-lts.iso')" +} + +variable "iso_checksum" { + type = string + description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-linux-ubuntu-server-18-04-lts.iso')" +} + +// Boot Settings + +variable "common_http_port_min" { + type = number + description = "The start of the HTTP port range." +} + +variable "common_http_port_max" { + type = number + description = "The end of the HTTP port range." +} + +variable "vm_boot_order" { + type = string + description = "The boot order for virtual machines devices." + default = "disk,cdrom" +} + +variable "vm_boot_wait" { + type = string + description = "The time to wait before boot." +} + +variable "common_ip_wait_timeout" { + type = string + description = "Time to wait for guest operating system IP address response." +} + +variable "common_shutdown_timeout" { + type = string + description = "Time to wait for guest operating system shutdown." +} + +// Communicator Settings and Credentials + +variable "build_username" { + type = string + description = "The username to login to the guest operating system. (e.g. rainpole)" + sensitive = true +} + +variable "build_password" { + type = string + description = "The password to login to the guest operating system." + sensitive = true +} + +variable "build_password_encrypted" { + type = string + description = "The encrypted password to login the guest operating system." + sensitive = true +} + +variable "build_key" { + type = string + description = "The public key to login to the guest operating system." + sensitive = true +} + +variable "communicator_port" { + type = string + description = "The port for the communicator protocol." +} + +variable "communicator_timeout" { + type = string + description = "The timeout for the communicator protocol." +} + +// Ansible Credentials + +variable "ansible_username" { + type = string + description = "The username for Ansible to login to the guest operating system. (e.g. ansible)" + sensitive = true +} + +variable "ansible_key" { + type = string + description = "The public key for Ansible to login to the guest operating system." + sensitive = true +} + +// Provisioner Settings + +variable "scripts" { + type = list(string) + description = "A list of scripts and their relative paths to transfer and execute." + default = [] +} + +variable "inline" { + type = list(string) + description = "A list of commands to execute." + default = [] +} \ No newline at end of file diff --git a/builds/linux/ubuntu-server-20-04-lts/http/user-data.pkrtpl.hcl b/builds/linux/ubuntu-server-20-04-lts/http/user-data.pkrtpl.hcl index 2a03c240a..5cd6f9545 100644 --- a/builds/linux/ubuntu-server-20-04-lts/http/user-data.pkrtpl.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/http/user-data.pkrtpl.hcl @@ -4,10 +4,9 @@ autoinstall: early-commands: # Ensures that Packer does not connect too soon. - sudo systemctl stop ssh - locale: en_US + locale: ${vm_guest_os_language} keyboard: - layout: en - variant: us + layout: ${vm_guest_os_keyboard} storage: layout: name: lvm @@ -37,4 +36,5 @@ autoinstall: - 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} - curtin in-target --target=/target -- apt-get update - - curtin in-target --target=/target -- apt-get upgrade --yes \ No newline at end of file + - curtin in-target --target=/target -- apt-get upgrade --yes + timezone: ${vm_guest_os_timezone} \ No newline at end of file diff --git a/builds/linux/ubuntu-server-20-04-lts/variables.auto.pkrvars.hcl b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.auto.pkrvars.hcl similarity index 79% rename from builds/linux/ubuntu-server-20-04-lts/variables.auto.pkrvars.hcl rename to builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.auto.pkrvars.hcl index 8031e36f7..1dde6ac19 100644 --- a/builds/linux/ubuntu-server-20-04-lts/variables.auto.pkrvars.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.auto.pkrvars.hcl @@ -4,10 +4,13 @@ */ // Guest Operating System Metadata -vm_guest_os_family = "linux" -vm_guest_os_vendor = "ubuntu" -vm_guest_os_member = "server" -vm_guest_os_version = "20-04-lts" +vm_guest_os_language = "en_US" +vm_guest_os_keyboard = "us" +vm_guest_os_timezone = "UTC" +vm_guest_os_family = "linux" +vm_guest_os_vendor = "ubuntu" +vm_guest_os_member = "server" +vm_guest_os_version = "20-04-lts" // Virtual Machine Guest Operating System Setting vm_guest_os_type = "ubuntu64Guest" @@ -30,8 +33,8 @@ iso_file = "iso-linux-ubuntu-server-20-04-lts.iso" iso_checksum = "302c990c6d69575ff24c96566e5c7e26bf36908abb0cd546e22687c46fb07bf8dba595bf77a9d4fd9ab63e75c0437c133f35462fd41ea77f6f616140cd0e5e6a" // Boot Settings -vm_boot_order = "disk,cdrom" -vm_boot_wait = "5s" +vm_boot_order = "disk,cdrom" +vm_boot_wait = "5s" // Communicator Settings communicator_port = 22 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 new file mode 100644 index 000000000..f06ba7111 --- /dev/null +++ b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl @@ -0,0 +1,127 @@ +/* + DESCRIPTION: + Ubuntu Server 20.04 LTS template using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: packer +// The Packer configuration. + +packer { + required_version = ">= 1.7.4" + required_plugins { + vsphere = { + version = ">= v1.0.1" + source = "github.com/hashicorp/vsphere" + } + } +} + +// BLOCK: locals +// Defines the local variables. + +locals { + buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) +} + +// BLOCK: source +// Defines the builder configuration blocks. + +source "vsphere-iso" "linux-ubuntu-server" { + + // vCenter Server Endpoint Settings and Credentials + vcenter_server = var.vsphere_endpoint + username = var.vsphere_username + password = var.vsphere_password + insecure_connection = var.vsphere_insecure_connection + + // vSphere Settings + datacenter = var.vsphere_datacenter + cluster = var.vsphere_cluster + datastore = var.vsphere_datastore + folder = var.vsphere_folder + + // Virtual Machine Settings + guest_os_type = var.vm_guest_os_type + vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" + firmware = var.vm_firmware + CPUs = var.vm_cpu_sockets + cpu_cores = var.vm_cpu_cores + CPU_hot_plug = var.vm_cpu_hot_add + RAM = var.vm_mem_size + RAM_hot_plug = var.vm_mem_hot_add + cdrom_type = var.vm_cdrom_type + disk_controller_type = var.vm_disk_controller_type + storage { + disk_size = var.vm_disk_size + disk_thin_provisioned = var.vm_disk_thin_provisioned + } + network_adapters { + network = var.vsphere_network + network_card = var.vm_network_card + } + vm_version = var.common_vm_version + remove_cdrom = var.common_remove_cdrom + tools_upgrade_policy = var.common_tools_upgrade_policy + notes = "Built by HashiCorp Packer on ${local.buildtime}." + + // Removable Media Settings + iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" + + // Boot and Provisioning Settings + http_port_min = var.common_http_port_min + http_port_max = var.common_http_port_max + http_content = { + "/meta-data" = file("http/meta-data") + "/user-data" = templatefile("http/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 }) + } + boot_order = var.vm_boot_order + boot_wait = var.vm_boot_wait + boot_command = [" ", "autoinstall ", "ip=dhcp ipv6.disable=1 ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ ", ""] + ip_wait_timeout = var.common_ip_wait_timeout + shutdown_command = "echo '${var.build_password}' | sudo -S -E shutdown -P now" + shutdown_timeout = var.common_shutdown_timeout + + // Communicator Settings and Credentials + communicator = "ssh" + ssh_username = var.build_username + ssh_password = var.build_password + ssh_port = var.communicator_port + ssh_timeout = var.communicator_timeout + + // Template and Content Library Settings + convert_to_template = var.common_template_conversion + content_library_destination { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } +} + +// BLOCK: build +// Defines the builders to run, provisioners, and post-processors. + +build { + sources = ["source.vsphere-iso.linux-ubuntu-server"] + + provisioner "file" { + destination = "/tmp/root-ca.crt" + source = "../../../certificates/root-ca.crt" + } + + provisioner "shell" { + execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" + environment_vars = [ + "BUILD_USERNAME=${var.build_username}", + "BUILD_KEY=${var.build_key}", + "ANSIBLE_USERNAME=${var.ansible_username}", + "ANSIBLE_KEY=${var.ansible_key}" + ] + scripts = var.scripts + } + + post-processor "manifest" { + output = "${path.cwd}/output/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}.json" + strip_path = false + } +} diff --git a/builds/linux/ubuntu-server-20-04-lts/output/.placeholder b/builds/linux/ubuntu-server-20-04-lts/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/linux/ubuntu-server-20-04-lts/ubuntu-server-20-04-lts.pkr.hcl b/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl similarity index 62% rename from builds/linux/ubuntu-server-20-04-lts/ubuntu-server-20-04-lts.pkr.hcl rename to builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl index 41d13f6be..36598b7a6 100644 --- a/builds/linux/ubuntu-server-20-04-lts/ubuntu-server-20-04-lts.pkr.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl @@ -1,21 +1,8 @@ /* DESCRIPTION: - Ubuntu Server 20.04 LTS template using the Packer Builder for VMware vSphere (vsphere-iso). + Ubuntu Server 20.04 LTS variables using the Packer Builder for VMware vSphere (vsphere-iso). */ -// BLOCK: packer -// The Packer configuration. - -packer { - required_version = ">= 1.7.4" - required_plugins { - vsphere = { - version = ">= v1.0.1" - source = "github.com/hashicorp/vsphere" - } - } -} - // BLOCK: variable // Defines the input variables. @@ -68,11 +55,29 @@ variable "vsphere_network" { variable "vsphere_folder" { type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" } // Virtual Machine Settings +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en_US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "us" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + variable "vm_guest_os_family" { type = string description = "The guest operating system family. Used for naming. (e.g.'linux')" @@ -80,7 +85,7 @@ variable "vm_guest_os_family" { variable "vm_guest_os_vendor" { type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'ubuntu')" + description = "The guest operating system vendor. Used for naming . (e.g. 'ubuntu')" } variable "vm_guest_os_member" { @@ -100,7 +105,7 @@ variable "vm_guest_os_type" { variable "vm_firmware" { type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" default = "bios" } @@ -216,7 +221,7 @@ variable "common_iso_path" { variable "common_iso_hash" { type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" } variable "iso_file" { @@ -243,13 +248,13 @@ variable "common_http_port_max" { variable "vm_boot_order" { type = string - description = "The time to wait before boot." + description = "The boot order for virtual machines devices." default = "disk,cdrom" } variable "vm_boot_wait" { type = string - description = "The boot order for virtual machines devices." + description = "The time to wait before boot." } variable "common_ip_wait_timeout" { @@ -278,13 +283,13 @@ variable "build_password" { variable "build_password_encrypted" { type = string - description = "The encrypted password for building the guest operating system." + description = "The encrypted password to login the guest operating system." sensitive = true } variable "build_key" { type = string - description = "The key to login to the guest operating system." + description = "The public key to login to the guest operating system." sensitive = true } @@ -308,7 +313,7 @@ variable "ansible_username" { variable "ansible_key" { type = string - description = "The key for Ansible to login to the guest operating system." + description = "The public key for Ansible to login to the guest operating system." sensitive = true } @@ -324,114 +329,4 @@ variable "inline" { type = list(string) description = "A list of commands to execute." default = [] -} - -// BLOCK: locals -// Defines the local variables. - -locals { - buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) -} - -// BLOCK: source -// Defines the builder configuration blocks. - -source "vsphere-iso" "linux-ubuntu-server" { - - // vCenter Server Endpoint Settings and Credentials - vcenter_server = var.vsphere_endpoint - username = var.vsphere_username - password = var.vsphere_password - insecure_connection = var.vsphere_insecure_connection - - // vSphere Settings - datacenter = var.vsphere_datacenter - cluster = var.vsphere_cluster - datastore = var.vsphere_datastore - folder = var.vsphere_folder - - // Virtual Machine Settings - guest_os_type = var.vm_guest_os_type - vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}" - firmware = var.vm_firmware - CPUs = var.vm_cpu_sockets - cpu_cores = var.vm_cpu_cores - CPU_hot_plug = var.vm_cpu_hot_add - RAM = var.vm_mem_size - RAM_hot_plug = var.vm_mem_hot_add - cdrom_type = var.vm_cdrom_type - disk_controller_type = var.vm_disk_controller_type - storage { - disk_size = var.vm_disk_size - disk_thin_provisioned = var.vm_disk_thin_provisioned - } - network_adapters { - network = var.vsphere_network - network_card = var.vm_network_card - } - vm_version = var.common_vm_version - remove_cdrom = var.common_remove_cdrom - tools_upgrade_policy = var.common_tools_upgrade_policy - notes = "Built by HashiCorp Packer on ${local.buildtime}." - - // Removable Media Settings - iso_paths = ["[${var.common_iso_datastore}] ${var.common_iso_path}/${var.iso_file}"] - iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" - - // Boot and Provisioning Settings - http_port_min = var.common_http_port_min - http_port_max = var.common_http_port_max - http_content = { - "/meta-data" = file("http/meta-data") - "/user-data" = templatefile("http/user-data.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted }) - } - boot_order = var.vm_boot_order - boot_wait = var.vm_boot_wait - boot_command = [" ", "autoinstall ", "ip=dhcp ipv6.disable=1 ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ ", ""] - ip_wait_timeout = var.common_ip_wait_timeout - shutdown_command = "echo '${var.build_password}' | sudo -S -E shutdown -P now" - shutdown_timeout = var.common_shutdown_timeout - - // Communicator Settings and Credentials - communicator = "ssh" - ssh_username = var.build_username - ssh_password = var.build_password - ssh_port = var.communicator_port - ssh_timeout = var.communicator_timeout - - // Template and Content Library Settings - convert_to_template = var.common_template_conversion - content_library_destination { - library = var.common_content_library_name - ovf = var.common_content_library_ovf - destroy = var.common_content_library_destroy - } -} - -// BLOCK: build -// Defines the builders to run, provisioners, and post-processors. - -build { - sources = ["source.vsphere-iso.linux-ubuntu-server"] - - provisioner "file" { - destination = "/tmp/root-ca.crt" - source = "../../../certificates/root-ca.crt" - } - - provisioner "shell" { - execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'" - environment_vars = [ - "BUILD_USERNAME=${var.build_username}", - "BUILD_KEY=${var.build_key}", - "ANSIBLE_USERNAME=${var.ansible_username}", - "ANSIBLE_KEY=${var.ansible_key}" - ] - scripts = var.scripts - } - - post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" - strip_path = false - } -} +} \ No newline at end of file diff --git a/builds/windows/windows-server-2016/cd/autounattend.pkrtpl.hcl b/builds/windows/windows-server-2016/cd/autounattend.pkrtpl.hcl index f4a9fe349..bee394880 100644 --- a/builds/windows/windows-server-2016/cd/autounattend.pkrtpl.hcl +++ b/builds/windows/windows-server-2016/cd/autounattend.pkrtpl.hcl @@ -3,13 +3,13 @@ - en-US + ${vm_guest_os_language} - en-US - en-US - en-US - en-US - en-US + ${vm_guest_os_keyboard} + e${vm_guest_os_language} + ${vm_guest_os_language} + ${vm_guest_os_language} + ${vm_guest_os_language} @@ -122,8 +122,8 @@ false - win-server-2019 - Pacific Standard Time + win-server-2016 + ${vm_guest_os_timezone} diff --git a/builds/windows/windows-server-2016/output/.placeholder b/builds/windows/windows-server-2016/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/windows/windows-server-2016/variables.pkr.hcl b/builds/windows/windows-server-2016/variables.pkr.hcl new file mode 100644 index 000000000..64d84845a --- /dev/null +++ b/builds/windows/windows-server-2016/variables.pkr.hcl @@ -0,0 +1,363 @@ +/* + DESCRIPTION: + Microsoft Windows Server 2016 Standard variables using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: variable +// Defines the input variables. + +// vSphere Credentials + +variable "vsphere_endpoint" { + type = string + description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')" +} + +variable "vsphere_username" { + type = string + description = "The username to login to the vCenter Server instance. (e.g. svc-packer-vsphere@rainpole.io)" + sensitive = true +} + +variable "vsphere_password" { + type = string + description = "The password for the login to the vCenter Server instance." + sensitive = true +} + +variable "vsphere_insecure_connection" { + type = bool + description = "Do not validate vCenter Server TLS certificate." + default = true +} + +// vSphere Settings + +variable "vsphere_datacenter" { + type = string + description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')" +} + +variable "vsphere_cluster" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')" +} + +variable "vsphere_datastore" { + type = string + description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')" +} + +variable "vsphere_network" { + type = string + description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')" +} + +variable "vsphere_folder" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" +} + +// Virtual Machine Settings + +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en-US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "en-US" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + +variable "vm_guest_os_vendor" { + type = string + description = "The guest operating system vendor. Used for naming . (e.g. 'microsoft)" +} + +variable "vm_guest_os_family" { + type = string + description = "The guest operating system family. Used for naming and VMware tools. (e.g.'windows')" +} + +variable "vm_guest_os_member" { + type = string + description = "The guest operating system member. Used for naming. (e.g. 'server')" +} + +variable "vm_guest_os_version" { + type = string + description = "The guest operating system version. Used for naming. (e.g. '2016')" +} + +variable "vm_guest_os_ed_standard" { + type = string + description = "The guest operating system edition. Used for naming. (e.g. 'standard')" + default = "standard" +} + +variable "vm_guest_os_ed_datacenter" { + type = string + description = "The guest operating system edition. Used for naming. (e.g. 'datacenter')" + default = "datacenter" +} + +variable "vm_guest_os_exp_minimal" { + type = string + description = "The guest operating system minimal experience. Used for naming. (e.g. 'core')" + default = "core" +} + +variable "vm_guest_os_exp_desktop" { + type = string + description = "The guest operating system desktop experience. Used for naming. (e.g. 'dexp')" + default = "desktop" +} + +variable "vm_guest_os_type" { + type = string + description = "The guest operating system type, also know as guestid. (e.g. 'windows9Server64Guest')" +} + +variable "vm_firmware" { + type = string + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" + default = "efi-secure" +} + +variable "vm_cdrom_type" { + type = string + description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')" + default = "sata" +} + +variable "vm_cpu_sockets" { + type = number + description = "The number of virtual CPUs sockets. (e.g. '2')" +} + +variable "vm_cpu_cores" { + type = number + description = "The number of virtual CPUs cores per socket. (e.g. '1')" +} + +variable "vm_cpu_hot_add" { + type = bool + description = "Enable hot add CPU." + default = false +} + +variable "vm_mem_size" { + type = number + description = "The size for the virtual memory in MB. (e.g. '2048')" +} + +variable "vm_mem_hot_add" { + type = bool + description = "Enable hot add memory." + default = false +} + +variable "vm_disk_size" { + type = number + description = "The size for the virtual disk in MB. (e.g. '40960')" +} + +variable "vm_disk_controller_type" { + type = list(string) + description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')" + default = ["pvscsi"] +} + +variable "vm_disk_thin_provisioned" { + type = bool + description = "Thin provision the virtual disk." + default = true +} + +variable "vm_network_card" { + type = string + description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')" + default = "vmxnet3" +} + +variable "common_vm_version" { + type = number + description = "The vSphere virtual hardware version. (e.g. '18')" +} + +variable "common_tools_upgrade_policy" { + type = bool + description = "Upgrade VMware Tools on reboot." + default = true +} + +variable "common_remove_cdrom" { + type = bool + description = "Remove the virtual CD-ROM(s)." + default = true +} + +// Template and Content Library Settings + +variable "common_template_conversion" { + type = bool + description = "Convert the virtual machine to template. Must be 'false' for content library." + default = false +} + +variable "common_content_library_name" { + type = string + description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" +} + +variable "common_content_library_ovf" { + type = bool + description = "Export to content library as an OVF template." + default = true +} + +variable "common_content_library_destroy" { + type = bool + description = "Delete the virtual machine afer exporting to the content library." + default = true +} + +// Removable Media Settings + +variable "common_iso_datastore" { + type = string + description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" +} + +variable "common_iso_path" { + type = string + description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" +} + +variable "common_iso_hash" { + type = string + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" +} + +variable "iso_file" { + type = string + description = "The file name of the ISO image. (e.g. 'iso-windows-server-2016.iso')" +} + +variable "iso_checksum" { + type = string + description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-server-2016.iso')" +} + +// Boot Settings + +variable "common_http_port_min" { + type = number + description = "The start of the HTTP port range." +} + +variable "common_http_port_max" { + type = number + 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." + default = "disk,cdrom" +} + +variable "vm_boot_wait" { + type = string + description = "The time to wait before boot." +} + +variable "vm_boot_command" { + type = list(string) + description = "The virtual machine boot command." + default = [] +} + +variable "vm_shutdown_command" { + type = string + description = "Command(s) for guest operating system shutdown." +} + +variable "common_ip_wait_timeout" { + type = string + description = "Time to wait for guest operating system IP address response." +} + +variable "common_shutdown_timeout" { + type = string + description = "Time to wait for guest operating system shutdown." +} + +// Communicator Settings and Credentials + +variable "build_username" { + type = string + description = "The username to login to the guest operating system. (e.g. rainpole)" + sensitive = true +} + +variable "build_password" { + type = string + description = "The password to login to the guest operating system." + sensitive = true +} + +variable "build_password_encrypted" { + type = string + description = "The encrypted password to login to the guest operating system." + sensitive = true + default = "" +} + +variable "build_key" { + type = string + description = "The public key to login to the guest operating system." + sensitive = true + default = "" +} + +// Communicator Credentials + +variable "communicator_port" { + type = string + description = "The port for the communicator protocol." +} + +variable "communicator_timeout" { + type = string + description = "The timeout for the communicator protocol." +} + +// Provisioner Settings + +variable "scripts" { + type = list(string) + description = "A list of scripts and their relative paths to transfer and execute." + default = [] +} + +variable "inline" { + type = list(string) + description = "A list of commands to execute." + default = [] +} \ No newline at end of file diff --git a/builds/windows/windows-server-2016/variables.auto.pkrvars.hcl b/builds/windows/windows-server-2016/windows-server.auto.pkrvars.hcl similarity index 94% rename from builds/windows/windows-server-2016/variables.auto.pkrvars.hcl rename to builds/windows/windows-server-2016/windows-server.auto.pkrvars.hcl index 912716ae0..9c96847bb 100644 --- a/builds/windows/windows-server-2016/variables.auto.pkrvars.hcl +++ b/builds/windows/windows-server-2016/windows-server.auto.pkrvars.hcl @@ -4,6 +4,9 @@ */ // Guest Operating System Metadata +vm_guest_os_language = "en-US" +vm_guest_os_keyboard = "en-US" +vm_guest_os_timezone = "UTC" vm_guest_os_vendor = "microsoft" vm_guest_os_family = "windows" vm_guest_os_member = "server" diff --git a/builds/windows/windows-server-2016/windows-server-2016.pkr.hcl b/builds/windows/windows-server-2016/windows-server.pkr.hcl similarity index 55% rename from builds/windows/windows-server-2016/windows-server-2016.pkr.hcl rename to builds/windows/windows-server-2016/windows-server.pkr.hcl index 16e1bce66..34fb341f5 100644 --- a/builds/windows/windows-server-2016/windows-server-2016.pkr.hcl +++ b/builds/windows/windows-server-2016/windows-server.pkr.hcl @@ -22,347 +22,6 @@ packer { } } -// BLOCK: variable -// Defines the input variables. - -// vSphere Credentials - -variable "vsphere_endpoint" { - type = string - description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')" -} - -variable "vsphere_username" { - type = string - description = "The username to login to the vCenter Server instance. (e.g. svc-packer-vsphere@rainpole.io)" - sensitive = true -} - -variable "vsphere_password" { - type = string - description = "The password for the login to the vCenter Server instance." - sensitive = true -} - -variable "vsphere_insecure_connection" { - type = bool - description = "Do not validate vCenter Server TLS certificate." - default = true -} - -// vSphere Settings - -variable "vsphere_datacenter" { - type = string - description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')" -} - -variable "vsphere_cluster" { - type = string - description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')" -} - -variable "vsphere_datastore" { - type = string - description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')" -} - -variable "vsphere_network" { - type = string - description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')" -} - -variable "vsphere_folder" { - type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" -} - -// Virtual Machine Settings - -variable "vm_guest_os_vendor" { - type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'microsoft)" -} - -variable "vm_guest_os_family" { - type = string - description = "The guest operating system family. Used for naming and VMware tools. (e.g.'windows')" -} - -variable "vm_guest_os_member" { - type = string - description = "The guest operating system member. Used for naming. (e.g. 'server')" -} - -variable "vm_guest_os_version" { - type = string - description = "The guest operating system version. Used for naming. (e.g. '2016')" -} - -variable "vm_guest_os_ed_standard" { - type = string - description = "The guest operating system edition. Used for naming. (e.g. 'standard')" - default = "standard" -} - -variable "vm_guest_os_ed_datacenter" { - type = string - description = "The guest operating system edition. Used for naming. (e.g. 'datacenter')" - default = "datacenter" -} - -variable "vm_guest_os_exp_minimal" { - type = string - description = "The guest operating system minimal experience. Used for naming. (e.g. 'core')" - default = "core" -} - -variable "vm_guest_os_exp_desktop" { - type = string - description = "The guest operating system desktop experience. Used for naming. (e.g. 'dexp')" - default = "desktop" -} - -variable "vm_guest_os_type" { - type = string - description = "The guest operating system type, also know as guestid. (e.g. 'windows9Server64Guest')" -} - -variable "vm_firmware" { - type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" - default = "efi-secure" -} - -variable "vm_cdrom_type" { - type = string - description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')" - default = "sata" -} - -variable "vm_cpu_sockets" { - type = number - description = "The number of virtual CPUs sockets. (e.g. '2')" -} - -variable "vm_cpu_cores" { - type = number - description = "The number of virtual CPUs cores per socket. (e.g. '1')" -} - -variable "vm_cpu_hot_add" { - type = bool - description = "Enable hot add CPU." - default = false -} - -variable "vm_mem_size" { - type = number - description = "The size for the virtual memory in MB. (e.g. '2048')" -} - -variable "vm_mem_hot_add" { - type = bool - description = "Enable hot add memory." - default = false -} - -variable "vm_disk_size" { - type = number - description = "The size for the virtual disk in MB. (e.g. '40960')" -} - -variable "vm_disk_controller_type" { - type = list(string) - description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')" - default = ["pvscsi"] -} - -variable "vm_disk_thin_provisioned" { - type = bool - description = "Thin provision the virtual disk." - default = true -} - -variable "vm_network_card" { - type = string - description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')" - default = "vmxnet3" -} - -variable "common_vm_version" { - type = number - description = "The vSphere virtual hardware version. (e.g. '18')" -} - -variable "common_tools_upgrade_policy" { - type = bool - description = "Upgrade VMware Tools on reboot." - default = true -} - -variable "common_remove_cdrom" { - type = bool - description = "Remove the virtual CD-ROM(s)." - default = true -} - -// Template and Content Library Settings - -variable "common_template_conversion" { - type = bool - description = "Convert the virtual machine to template. Must be 'false' for content library." - default = false -} - -variable "common_content_library_name" { - type = string - description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" -} - -variable "common_content_library_ovf" { - type = bool - description = "Export to content library as an OVF template." - default = true -} - -variable "common_content_library_destroy" { - type = bool - description = "Delete the virtual machine afer exporting to the content library." - default = true -} - -// Removable Media Settings - -variable "common_iso_datastore" { - type = string - description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" -} - -variable "common_iso_path" { - type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" -} - -variable "common_iso_hash" { - type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" -} - -variable "iso_file" { - type = string - description = "The file name of the ISO image. (e.g. 'iso-windows-server-2016.iso')" -} - -variable "iso_checksum" { - type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-server-2016.iso')" -} - -// Boot Settings - -variable "common_http_port_min" { - type = number - description = "The start of the HTTP port range." -} - -variable "common_http_port_max" { - type = number - 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 time to wait before boot." - default = "disk,cdrom" -} - -variable "vm_boot_wait" { - type = string - description = "The boot order for virtual machines devices." -} - -variable "vm_boot_command" { - type = list(string) - description = "The virtual machine boot command." - default = [] -} - -variable "vm_shutdown_command" { - type = string - description = "Command(s) for guest operating system shutdown." -} - -variable "common_ip_wait_timeout" { - type = string - description = "Time to wait for guest operating system IP address response." -} - -variable "common_shutdown_timeout" { - type = string - description = "Time to wait for guest operating system shutdown." -} - -// Communicator Settings and Credentials - -variable "build_username" { - type = string - description = "The username to login to the guest operating system. (e.g. rainpole)" - sensitive = true -} - -variable "build_password" { - type = string - description = "The password to login to the guest operating system." - sensitive = true -} - -variable "build_password_encrypted" { - type = string - description = "The encrypted password for building the guest operating system." - sensitive = true - default = "" -} - -variable "build_key" { - type = string - description = "The public key to login to the guest operating system." - sensitive = true - default = "" -} - -// Communicator Credentials - -variable "communicator_port" { - type = string - description = "The port for the communicator protocol." -} - -variable "communicator_timeout" { - type = string - description = "The timeout for the communicator protocol." -} - -// Provisioner Settings - -variable "scripts" { - type = list(string) - description = "A list of scripts and their relative paths to transfer and execute." - default = [] -} - -variable "inline" { - type = list(string) - description = "A list of commands to execute." - default = [] -} - // BLOCK: locals // Defines the local variables. @@ -417,9 +76,9 @@ source "vsphere-iso" "windows-server-standard-core" { cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -492,9 +151,9 @@ source "vsphere-iso" "windows-server-standard-dexp" { cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -568,9 +227,9 @@ source "vsphere-iso" "windows-server-datacenter-core" { cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -644,9 +303,9 @@ source "vsphere-iso" "windows-server-datacenter-dexp" { cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -695,15 +354,15 @@ build { environment_vars = [ "BUILD_USERNAME=${var.build_username}" ] - elevated_user = var.build_username - elevated_password = var.build_password - scripts = var.scripts + elevated_user = var.build_username + elevated_password = var.build_password + scripts = var.scripts } provisioner "powershell" { - elevated_user = var.build_username - elevated_password = var.build_password - inline = var.inline + elevated_user = var.build_username + elevated_password = var.build_password + inline = var.inline } provisioner "windows-update" { @@ -720,7 +379,7 @@ build { } post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" + output = "${path.cwd}/output/${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/cd/autounattend.pkrtpl.hcl b/builds/windows/windows-server-2019/cd/autounattend.pkrtpl.hcl index f4a9fe349..c15f84b0b 100644 --- a/builds/windows/windows-server-2019/cd/autounattend.pkrtpl.hcl +++ b/builds/windows/windows-server-2019/cd/autounattend.pkrtpl.hcl @@ -3,13 +3,13 @@ - en-US + ${vm_guest_os_language} - en-US - en-US - en-US - en-US - en-US + ${vm_guest_os_keyboard} + e${vm_guest_os_language} + ${vm_guest_os_language} + ${vm_guest_os_language} + ${vm_guest_os_language} @@ -123,7 +123,7 @@ false win-server-2019 - Pacific Standard Time + ${vm_guest_os_timezone} diff --git a/builds/windows/windows-server-2019/output/.placeholder b/builds/windows/windows-server-2019/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/windows/windows-server-2019/variables.pkr.hcl b/builds/windows/windows-server-2019/variables.pkr.hcl new file mode 100644 index 000000000..3a6df7103 --- /dev/null +++ b/builds/windows/windows-server-2019/variables.pkr.hcl @@ -0,0 +1,357 @@ +/* + DESCRIPTION: + Microsoft Windows Server 2019 Standard variables using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: variable +// Defines the input variables. + +// vSphere Credentials + +variable "vsphere_endpoint" { + type = string + description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')" +} + +variable "vsphere_username" { + type = string + description = "The username to login to the vCenter Server instance. (e.g. svc-packer-vsphere@rainpole.io)" + sensitive = true +} + +variable "vsphere_password" { + type = string + description = "The password for the login to the vCenter Server instance." + sensitive = true +} + +variable "vsphere_insecure_connection" { + type = bool + description = "Do not validate vCenter Server TLS certificate." + default = true +} + +// vSphere Settings + +variable "vsphere_datacenter" { + type = string + description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')" +} + +variable "vsphere_cluster" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')" +} + +variable "vsphere_datastore" { + type = string + description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')" +} + +variable "vsphere_network" { + type = string + description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')" +} + +variable "vsphere_folder" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" +} + +// Virtual Machine Settings + +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en-US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "en-US" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + +variable "vm_guest_os_vendor" { + type = string + description = "The guest operating system vendor. Used for naming . (e.g. 'microsoft)" +} + +variable "vm_guest_os_family" { + type = string + description = "The guest operating system family. Used for naming and VMware tools. (e.g.'windows')" +} + +variable "vm_guest_os_member" { + type = string + description = "The guest operating system member. Used for naming. (e.g. 'server')" +} + +variable "vm_guest_os_version" { + type = string + description = "The guest operating system version. Used for naming. (e.g. '2019')" +} + +variable "vm_guest_os_ed_standard" { + type = string + description = "The guest operating system edition. Used for naming. (e.g. 'standard')" + default = "standard" +} + +variable "vm_guest_os_ed_datacenter" { + type = string + description = "The guest operating system edition. Used for naming. (e.g. 'datacenter')" + default = "datacenter" +} + +variable "vm_guest_os_exp_minimal" { + type = string + description = "The guest operating system minimal experience. Used for naming. (e.g. 'core')" + default = "core" +} + +variable "vm_guest_os_exp_desktop" { + type = string + description = "The guest operating system desktop experience. Used for naming. (e.g. 'dexp')" + default = "desktop" +} + +variable "vm_guest_os_type" { + type = string + description = "The guest operating system type, also know as guestid. (e.g. 'windows2019srv_64Guest')" +} + +variable "vm_firmware" { + type = string + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" + default = "efi-secure" +} + +variable "vm_cdrom_type" { + type = string + description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')" + default = "sata" +} + +variable "vm_cpu_sockets" { + type = number + description = "The number of virtual CPUs sockets. (e.g. '2')" +} + +variable "vm_cpu_cores" { + type = number + description = "The number of virtual CPUs cores per socket. (e.g. '1')" +} + +variable "vm_cpu_hot_add" { + type = bool + description = "Enable hot add CPU." + default = false +} + +variable "vm_mem_size" { + type = number + description = "The size for the virtual memory in MB. (e.g. '2048')" +} + +variable "vm_mem_hot_add" { + type = bool + description = "Enable hot add memory." + default = false +} + +variable "vm_disk_size" { + type = number + description = "The size for the virtual disk in MB. (e.g. '40960')" +} + +variable "vm_disk_controller_type" { + type = list(string) + description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')" + default = ["pvscsi"] +} + +variable "vm_disk_thin_provisioned" { + type = bool + description = "Thin provision the virtual disk." + default = true +} + +variable "vm_network_card" { + type = string + description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')" + default = "vmxnet3" +} + +variable "common_vm_version" { + type = number + description = "The vSphere virtual hardware version. (e.g. '18')" +} + +variable "common_tools_upgrade_policy" { + type = bool + description = "Upgrade VMware Tools on reboot." + default = true +} + +variable "common_remove_cdrom" { + type = bool + description = "Remove the virtual CD-ROM(s)." + default = true +} + +// Template and Content Library Settings + +variable "common_template_conversion" { + type = bool + description = "Convert the virtual machine to template. Must be 'false' for content library." + default = false +} + +variable "common_content_library_name" { + type = string + description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" +} + +variable "common_content_library_ovf" { + type = bool + description = "Export to content library as an OVF template." + default = true +} + +variable "common_content_library_destroy" { + type = bool + description = "Delete the virtual machine afer exporting to the content library." + default = true +} + +// Removable Media Settings + +variable "common_iso_datastore" { + type = string + description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" +} + +variable "common_iso_path" { + type = string + description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" +} + +variable "common_iso_hash" { + type = string + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" +} + +variable "iso_file" { + type = string + description = "The file name of the ISO image. (e.g. 'iso-windows-server-2019.iso')" +} + +variable "iso_checksum" { + type = string + description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-server-2019.iso')" +} + +// Boot Settings + +variable "common_http_port_min" { + type = number + description = "The start of the HTTP port range." +} + +variable "common_http_port_max" { + type = number + description = "The end of the HTTP port range." +} + +variable "vm_boot_order" { + type = string + description = "The boot order for virtual machines devices." + default = "disk,cdrom" +} + +variable "vm_boot_wait" { + type = string + description = "The time to wait before boot." +} + +variable "vm_boot_command" { + type = list(string) + description = "The virtual machine boot command." + default = [] +} + +variable "vm_shutdown_command" { + type = string + description = "Command(s) for guest operating system shutdown." +} + +variable "common_ip_wait_timeout" { + type = string + description = "Time to wait for guest operating system IP address response." +} + +variable "common_shutdown_timeout" { + type = string + description = "Time to wait for guest operating system shutdown." +} + +// Communicator Settings and Credentials + +variable "build_username" { + type = string + description = "The username to login to the guest operating system. (e.g. rainpole)" + sensitive = true +} + +variable "build_password" { + type = string + description = "The password to login to the guest operating system." + sensitive = true +} + +variable "build_password_encrypted" { + type = string + description = "The encrypted password to login to the guest operating system." + sensitive = true + default = "" +} + +variable "build_key" { + type = string + description = "The public key to login to the guest operating system." + sensitive = true + default = "" +} + +// Communicator Credentials + +variable "communicator_port" { + type = string + description = "The port for the communicator protocol." +} + +variable "communicator_timeout" { + type = string + description = "The timeout for the communicator protocol." +} + +// Provisioner Settings + +variable "scripts" { + type = list(string) + description = "A list of scripts and their relative paths to transfer and execute." + default = [] +} + +variable "inline" { + type = list(string) + description = "A list of commands to execute." + default = [] +} \ No newline at end of file diff --git a/builds/windows/windows-server-2019/variables.auto.pkrvars.hcl b/builds/windows/windows-server-2019/windows-server.auto.pkrvars.hcl similarity index 94% rename from builds/windows/windows-server-2019/variables.auto.pkrvars.hcl rename to builds/windows/windows-server-2019/windows-server.auto.pkrvars.hcl index 972ca9f10..5966362bc 100644 --- a/builds/windows/windows-server-2019/variables.auto.pkrvars.hcl +++ b/builds/windows/windows-server-2019/windows-server.auto.pkrvars.hcl @@ -4,6 +4,9 @@ */ // Guest Operating System Metadata +vm_guest_os_language = "en-US" +vm_guest_os_keyboard = "en-US" +vm_guest_os_timezone = "UTC" vm_guest_os_vendor = "microsoft" vm_guest_os_family = "windows" vm_guest_os_member = "server" diff --git a/builds/windows/windows-server-2019/windows-server-2019.pkr.hcl b/builds/windows/windows-server-2019/windows-server.pkr.hcl similarity index 52% rename from builds/windows/windows-server-2019/windows-server-2019.pkr.hcl rename to builds/windows/windows-server-2019/windows-server.pkr.hcl index 5d17b5677..ab7a9ab9e 100644 --- a/builds/windows/windows-server-2019/windows-server-2019.pkr.hcl +++ b/builds/windows/windows-server-2019/windows-server.pkr.hcl @@ -22,341 +22,6 @@ packer { } } -// BLOCK: variable -// Defines the input variables. - -// vSphere Credentials - -variable "vsphere_endpoint" { - type = string - description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')" -} - -variable "vsphere_username" { - type = string - description = "The username to login to the vCenter Server instance. (e.g. svc-packer-vsphere@rainpole.io)" - sensitive = true -} - -variable "vsphere_password" { - type = string - description = "The password for the login to the vCenter Server instance." - sensitive = true -} - -variable "vsphere_insecure_connection" { - type = bool - description = "Do not validate vCenter Server TLS certificate." - default = true -} - -// vSphere Settings - -variable "vsphere_datacenter" { - type = string - description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')" -} - -variable "vsphere_cluster" { - type = string - description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')" -} - -variable "vsphere_datastore" { - type = string - description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')" -} - -variable "vsphere_network" { - type = string - description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')" -} - -variable "vsphere_folder" { - type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" -} - -// Virtual Machine Settings - -variable "vm_guest_os_vendor" { - type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'microsoft)" -} - -variable "vm_guest_os_family" { - type = string - description = "The guest operating system family. Used for naming and VMware tools. (e.g.'windows')" -} - -variable "vm_guest_os_member" { - type = string - description = "The guest operating system member. Used for naming. (e.g. 'server')" -} - -variable "vm_guest_os_version" { - type = string - description = "The guest operating system version. Used for naming. (e.g. '2019')" -} - -variable "vm_guest_os_ed_standard" { - type = string - description = "The guest operating system edition. Used for naming. (e.g. 'standard')" - default = "standard" -} - -variable "vm_guest_os_ed_datacenter" { - type = string - description = "The guest operating system edition. Used for naming. (e.g. 'datacenter')" - default = "datacenter" -} - -variable "vm_guest_os_exp_minimal" { - type = string - description = "The guest operating system minimal experience. Used for naming. (e.g. 'core')" - default = "core" -} - -variable "vm_guest_os_exp_desktop" { - type = string - description = "The guest operating system desktop experience. Used for naming. (e.g. 'dexp')" - default = "desktop" -} - -variable "vm_guest_os_type" { - type = string - description = "The guest operating system type, also know as guestid. (e.g. 'windows2019srv_64Guest')" -} - -variable "vm_firmware" { - type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" - default = "efi-secure" -} - -variable "vm_cdrom_type" { - type = string - description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')" - default = "sata" -} - -variable "vm_cpu_sockets" { - type = number - description = "The number of virtual CPUs sockets. (e.g. '2')" -} - -variable "vm_cpu_cores" { - type = number - description = "The number of virtual CPUs cores per socket. (e.g. '1')" -} - -variable "vm_cpu_hot_add" { - type = bool - description = "Enable hot add CPU." - default = false -} - -variable "vm_mem_size" { - type = number - description = "The size for the virtual memory in MB. (e.g. '2048')" -} - -variable "vm_mem_hot_add" { - type = bool - description = "Enable hot add memory." - default = false -} - -variable "vm_disk_size" { - type = number - description = "The size for the virtual disk in MB. (e.g. '40960')" -} - -variable "vm_disk_controller_type" { - type = list(string) - description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')" - default = ["pvscsi"] -} - -variable "vm_disk_thin_provisioned" { - type = bool - description = "Thin provision the virtual disk." - default = true -} - -variable "vm_network_card" { - type = string - description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')" - default = "vmxnet3" -} - -variable "common_vm_version" { - type = number - description = "The vSphere virtual hardware version. (e.g. '18')" -} - -variable "common_tools_upgrade_policy" { - type = bool - description = "Upgrade VMware Tools on reboot." - default = true -} - -variable "common_remove_cdrom" { - type = bool - description = "Remove the virtual CD-ROM(s)." - default = true -} - -// Template and Content Library Settings - -variable "common_template_conversion" { - type = bool - description = "Convert the virtual machine to template. Must be 'false' for content library." - default = false -} - -variable "common_content_library_name" { - type = string - description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" -} - -variable "common_content_library_ovf" { - type = bool - description = "Export to content library as an OVF template." - default = true -} - -variable "common_content_library_destroy" { - type = bool - description = "Delete the virtual machine afer exporting to the content library." - default = true -} - -// Removable Media Settings - -variable "common_iso_datastore" { - type = string - description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" -} - -variable "common_iso_path" { - type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" -} - -variable "common_iso_hash" { - type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" -} - -variable "iso_file" { - type = string - description = "The file name of the ISO image. (e.g. 'iso-windows-server-2019.iso')" -} - -variable "iso_checksum" { - type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-server-2019.iso')" -} - -// Boot Settings - -variable "common_http_port_min" { - type = number - description = "The start of the HTTP port range." -} - -variable "common_http_port_max" { - type = number - description = "The end of the HTTP port range." -} - -variable "vm_boot_order" { - type = string - description = "The time to wait before boot." - default = "disk,cdrom" -} - -variable "vm_boot_wait" { - type = string - description = "The boot order for virtual machines devices." -} - -variable "vm_boot_command" { - type = list(string) - description = "The virtual machine boot command." - default = [] -} - -variable "vm_shutdown_command" { - type = string - description = "Command(s) for guest operating system shutdown." -} - -variable "common_ip_wait_timeout" { - type = string - description = "Time to wait for guest operating system IP address response." -} - -variable "common_shutdown_timeout" { - type = string - description = "Time to wait for guest operating system shutdown." -} - -// Communicator Settings and Credentials - -variable "build_username" { - type = string - description = "The username to login to the guest operating system. (e.g. rainpole)" - sensitive = true -} - -variable "build_password" { - type = string - description = "The password to login to the guest operating system." - sensitive = true -} - -variable "build_password_encrypted" { - type = string - description = "The encrypted password for building the guest operating system." - sensitive = true - default = "" -} - -variable "build_key" { - type = string - description = "The public key to login to the guest operating system." - sensitive = true - default = "" -} - -// Communicator Credentials - -variable "communicator_port" { - type = string - description = "The port for the communicator protocol." -} - -variable "communicator_timeout" { - type = string - description = "The timeout for the communicator protocol." -} - -// Provisioner Settings - -variable "scripts" { - type = list(string) - description = "A list of scripts and their relative paths to transfer and execute." - default = [] -} - -variable "inline" { - type = list(string) - description = "A list of commands to execute." - default = [] -} - // BLOCK: locals // Defines the local variables. @@ -406,14 +71,14 @@ 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.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -482,14 +147,14 @@ 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.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -558,14 +223,14 @@ 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.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -634,14 +299,14 @@ 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.common_iso_path}/${var.iso_file}", "[] /vmimages/tools-isoimages/${var.vm_guest_os_family}.iso"] + iso_checksum = "${var.common_iso_hash}:${var.iso_checksum}" cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -690,15 +355,15 @@ build { environment_vars = [ "BUILD_USERNAME=${var.build_username}" ] - elevated_user = var.build_username - elevated_password = var.build_password - scripts = var.scripts + elevated_user = var.build_username + elevated_password = var.build_password + scripts = var.scripts } provisioner "powershell" { - elevated_user = var.build_username - elevated_password = var.build_password - inline = var.inline + elevated_user = var.build_username + elevated_password = var.build_password + inline = var.inline } provisioner "windows-update" { @@ -715,7 +380,7 @@ build { } post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" + output = "${path.cwd}/output/${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/cd/autounattend.pkrtpl.hcl b/builds/windows/windows-server-2022/cd/autounattend.pkrtpl.hcl index f4a9fe349..e8c3e459e 100644 --- a/builds/windows/windows-server-2022/cd/autounattend.pkrtpl.hcl +++ b/builds/windows/windows-server-2022/cd/autounattend.pkrtpl.hcl @@ -3,13 +3,13 @@ - en-US + ${vm_guest_os_language} - en-US - en-US - en-US - en-US - en-US + ${vm_guest_os_keyboard} + e${vm_guest_os_language} + ${vm_guest_os_language} + ${vm_guest_os_language} + ${vm_guest_os_language} @@ -122,8 +122,8 @@ false - win-server-2019 - Pacific Standard Time + win-server-2022 + ${vm_guest_os_timezone} diff --git a/builds/windows/windows-server-2022/output/.placeholder b/builds/windows/windows-server-2022/output/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/builds/windows/windows-server-2022/variables.pkr.hcl b/builds/windows/windows-server-2022/variables.pkr.hcl new file mode 100644 index 000000000..f5804d145 --- /dev/null +++ b/builds/windows/windows-server-2022/variables.pkr.hcl @@ -0,0 +1,357 @@ +/* + DESCRIPTION: + Microsoft Windows Server 2022 Standard variables using the Packer Builder for VMware vSphere (vsphere-iso). +*/ + +// BLOCK: variable +// Defines the input variables. + +// vSphere Credentials + +variable "vsphere_endpoint" { + type = string + description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')" +} + +variable "vsphere_username" { + type = string + description = "The username to login to the vCenter Server instance. (e.g. svc-packer-vsphere@rainpole.io)" + sensitive = true +} + +variable "vsphere_password" { + type = string + description = "The password for the login to the vCenter Server instance." + sensitive = true +} + +variable "vsphere_insecure_connection" { + type = bool + description = "Do not validate vCenter Server TLS certificate." + default = true +} + +// vSphere Settings + +variable "vsphere_datacenter" { + type = string + description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')" +} + +variable "vsphere_cluster" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')" +} + +variable "vsphere_datastore" { + type = string + description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')" +} + +variable "vsphere_network" { + type = string + description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')" +} + +variable "vsphere_folder" { + type = string + description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')" +} + +// Virtual Machine Settings + +variable "vm_guest_os_language" { + type = string + description = "The guest operating system lanugage." + default = "en-US" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "The guest operating system keyboard input." + default = "en-US" +} + +variable "vm_guest_os_timezone" { + type = string + description = "The guest operating system timezone." + default = "UTC" +} + +variable "vm_guest_os_vendor" { + type = string + description = "The guest operating system vendor. Used for naming . (e.g. 'microsoft)" +} + +variable "vm_guest_os_family" { + type = string + description = "The guest operating system family. Used for naming and VMware tools. (e.g.'windows')" +} + +variable "vm_guest_os_member" { + type = string + description = "The guest operating system member. Used for naming. (e.g. 'server')" +} + +variable "vm_guest_os_version" { + type = string + description = "The guest operating system version. Used for naming. (e.g. '2022')" +} + +variable "vm_guest_os_ed_standard" { + type = string + description = "The guest operating system edition. Used for naming. (e.g. 'standard')" + default = "standard" +} + +variable "vm_guest_os_ed_datacenter" { + type = string + description = "The guest operating system edition. Used for naming. (e.g. 'datacenter')" + default = "datacenter" +} + +variable "vm_guest_os_exp_minimal" { + type = string + description = "The guest operating system minimal experience. Used for naming. (e.g. 'core')" + default = "core" +} + +variable "vm_guest_os_exp_desktop" { + type = string + description = "The guest operating system desktop experience. Used for naming. (e.g. 'dexp')" + default = "desktop" +} + +variable "vm_guest_os_type" { + type = string + description = "The guest operating system type, also know as guestid. (e.g. 'windows2019srv_64Guest')" +} + +variable "vm_firmware" { + type = string + description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')" + default = "efi-secure" +} + +variable "vm_cdrom_type" { + type = string + description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')" + default = "sata" +} + +variable "vm_cpu_sockets" { + type = number + description = "The number of virtual CPUs sockets. (e.g. '2')" +} + +variable "vm_cpu_cores" { + type = number + description = "The number of virtual CPUs cores per socket. (e.g. '1')" +} + +variable "vm_cpu_hot_add" { + type = bool + description = "Enable hot add CPU." + default = true +} + +variable "vm_mem_size" { + type = number + description = "The size for the virtual memory in MB. (e.g. '2048')" +} + +variable "vm_mem_hot_add" { + type = bool + description = "Enable hot add memory." + default = true +} + +variable "vm_disk_size" { + type = number + description = "The size for the virtual disk in MB. (e.g. '40960')" +} + +variable "vm_disk_controller_type" { + type = list(string) + description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')" + default = ["pvscsi"] +} + +variable "vm_disk_thin_provisioned" { + type = bool + description = "Thin provision the virtual disk." + default = true +} + +variable "vm_network_card" { + type = string + description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')" + default = "vmxnet3" +} + +variable "common_vm_version" { + type = number + description = "The vSphere virtual hardware version. (e.g. '18')" +} + +variable "common_tools_upgrade_policy" { + type = bool + description = "Upgrade VMware Tools on reboot." + default = true +} + +variable "common_remove_cdrom" { + type = bool + description = "Remove the virtual CD-ROM(s)." + default = true +} + +// Template and Content Library Settings + +variable "common_template_conversion" { + type = bool + description = "Convert the virtual machine to template. Must be 'false' for content library." + default = false +} + +variable "common_content_library_name" { + type = string + description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" +} + +variable "common_content_library_ovf" { + type = bool + description = "Export to content library as an OVF template." + default = true +} + +variable "common_content_library_destroy" { + type = bool + description = "Delete the virtual machine afer exporting to the content library." + default = true +} + +// Removable Media Settings + +variable "common_iso_datastore" { + type = string + description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" +} + +variable "common_iso_path" { + type = string + description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" +} + +variable "common_iso_hash" { + type = string + description = "The algorithm used for the checkcum of the ISO image. (e.g. 'sha512')" +} + +variable "iso_file" { + type = string + description = "The file name of the ISO image. (e.g. 'iso-windows-server-2019.iso')" +} + +variable "iso_checksum" { + type = string + description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-server-2019.iso')" +} + +// Boot Settings + +variable "common_http_port_min" { + type = number + description = "The start of the HTTP port range." +} + +variable "common_http_port_max" { + type = number + description = "The end of the HTTP port range." +} + +variable "vm_boot_order" { + type = string + description = "The boot order for virtual machines devices." + default = "disk,cdrom" +} + +variable "vm_boot_wait" { + type = string + description = "The time to wait before boot." +} + +variable "vm_boot_command" { + type = list(string) + description = "The virtual machine boot command." + default = [] +} + +variable "vm_shutdown_command" { + type = string + description = "Command(s) for guest operating system shutdown." +} + +variable "common_ip_wait_timeout" { + type = string + description = "Time to wait for guest operating system IP address response." +} + +variable "common_shutdown_timeout" { + type = string + description = "Time to wait for guest operating system shutdown." +} + +// Communicator Settings and Credentials + +variable "build_username" { + type = string + description = "The username to login to the guest operating system. (e.g. rainpole)" + sensitive = true +} + +variable "build_password" { + type = string + description = "The password to login to the guest operating system." + sensitive = true +} + +variable "build_password_encrypted" { + type = string + description = "The encrypted password to login to the guest operating system." + sensitive = true + default = "" +} + +variable "build_key" { + type = string + description = "The public key to login to the guest operating system." + sensitive = true + default = "" +} + +// Communicator Credentials + +variable "communicator_port" { + type = string + description = "The port for the communicator protocol." +} + +variable "communicator_timeout" { + type = string + description = "The timeout for the communicator protocol." +} + +// Provisioner Settings + +variable "scripts" { + type = list(string) + description = "A list of scripts and their relative paths to transfer and execute." + default = [] +} + +variable "inline" { + type = list(string) + description = "A list of commands to execute." + default = [] +} \ No newline at end of file diff --git a/builds/windows/windows-server-2022/variables.auto.pkrvars.hcl b/builds/windows/windows-server-2022/windows-server.auto.pkrvars.hcl similarity index 94% rename from builds/windows/windows-server-2022/variables.auto.pkrvars.hcl rename to builds/windows/windows-server-2022/windows-server.auto.pkrvars.hcl index 1ad4a6e28..541e1498f 100644 --- a/builds/windows/windows-server-2022/variables.auto.pkrvars.hcl +++ b/builds/windows/windows-server-2022/windows-server.auto.pkrvars.hcl @@ -4,6 +4,9 @@ */ // Guest Operating System Metadata +vm_guest_os_language = "en-US" +vm_guest_os_keyboard = "en-US" +vm_guest_os_timezone = "UTC" vm_guest_os_vendor = "microsoft" vm_guest_os_family = "windows" vm_guest_os_member = "server" diff --git a/builds/windows/windows-server-2022/windows-server-2022.pkr.hcl b/builds/windows/windows-server-2022/windows-server.pkr.hcl similarity index 56% rename from builds/windows/windows-server-2022/windows-server-2022.pkr.hcl rename to builds/windows/windows-server-2022/windows-server.pkr.hcl index f2e0edabc..1125d0348 100644 --- a/builds/windows/windows-server-2022/windows-server-2022.pkr.hcl +++ b/builds/windows/windows-server-2022/windows-server.pkr.hcl @@ -22,341 +22,6 @@ packer { } } -// BLOCK: variable -// Defines the input variables. - -// vSphere Credentials - -variable "vsphere_endpoint" { - type = string - description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')" -} - -variable "vsphere_username" { - type = string - description = "The username to login to the vCenter Server instance. (e.g. svc-packer-vsphere@rainpole.io)" - sensitive = true -} - -variable "vsphere_password" { - type = string - description = "The password for the login to the vCenter Server instance." - sensitive = true -} - -variable "vsphere_insecure_connection" { - type = bool - description = "Do not validate vCenter Server TLS certificate." - default = true -} - -// vSphere Settings - -variable "vsphere_datacenter" { - type = string - description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')" -} - -variable "vsphere_cluster" { - type = string - description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')" -} - -variable "vsphere_datastore" { - type = string - description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')" -} - -variable "vsphere_network" { - type = string - description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')" -} - -variable "vsphere_folder" { - type = string - description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')" -} - -// Virtual Machine Settings - -variable "vm_guest_os_vendor" { - type = string - description = "The guest operating system vendor. Used for naming. (e.g. 'microsoft)" -} - -variable "vm_guest_os_family" { - type = string - description = "The guest operating system family. Used for naming and VMware tools. (e.g.'windows')" -} - -variable "vm_guest_os_member" { - type = string - description = "The guest operating system member. Used for naming. (e.g. 'server')" -} - -variable "vm_guest_os_version" { - type = string - description = "The guest operating system version. Used for naming. (e.g. '2022')" -} - -variable "vm_guest_os_ed_standard" { - type = string - description = "The guest operating system edition. Used for naming. (e.g. 'standard')" - default = "standard" -} - -variable "vm_guest_os_ed_datacenter" { - type = string - description = "The guest operating system edition. Used for naming. (e.g. 'datacenter')" - default = "datacenter" -} - -variable "vm_guest_os_exp_minimal" { - type = string - description = "The guest operating system minimal experience. Used for naming. (e.g. 'core')" - default = "core" -} - -variable "vm_guest_os_exp_desktop" { - type = string - description = "The guest operating system desktop experience. Used for naming. (e.g. 'dexp')" - default = "desktop" -} - -variable "vm_guest_os_type" { - type = string - description = "The guest operating system type, also know as guestid. (e.g. 'windows2019srv_64Guest')" -} - -variable "vm_firmware" { - type = string - description = "The virtual machine firmware. (e.g. 'efi-secure' or 'bios')" - default = "efi-secure" -} - -variable "vm_cdrom_type" { - type = string - description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')" - default = "sata" -} - -variable "vm_cpu_sockets" { - type = number - description = "The number of virtual CPUs sockets. (e.g. '2')" -} - -variable "vm_cpu_cores" { - type = number - description = "The number of virtual CPUs cores per socket. (e.g. '1')" -} - -variable "vm_cpu_hot_add" { - type = bool - description = "Enable hot add CPU." - default = false -} - -variable "vm_mem_size" { - type = number - description = "The size for the virtual memory in MB. (e.g. '2048')" -} - -variable "vm_mem_hot_add" { - type = bool - description = "Enable hot add memory." - default = false -} - -variable "vm_disk_size" { - type = number - description = "The size for the virtual disk in MB. (e.g. '40960')" -} - -variable "vm_disk_controller_type" { - type = list(string) - description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')" - default = ["pvscsi"] -} - -variable "vm_disk_thin_provisioned" { - type = bool - description = "Thin provision the virtual disk." - default = true -} - -variable "vm_network_card" { - type = string - description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')" - default = "vmxnet3" -} - -variable "common_vm_version" { - type = number - description = "The vSphere virtual hardware version. (e.g. '18')" -} - -variable "common_tools_upgrade_policy" { - type = bool - description = "Upgrade VMware Tools on reboot." - default = true -} - -variable "common_remove_cdrom" { - type = bool - description = "Remove the virtual CD-ROM(s)." - default = true -} - -// Template and Content Library Settings - -variable "common_template_conversion" { - type = bool - description = "Convert the virtual machine to template. Must be 'false' for content library." - default = false -} - -variable "common_content_library_name" { - type = string - description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" -} - -variable "common_content_library_ovf" { - type = bool - description = "Export to content library as an OVF template." - default = true -} - -variable "common_content_library_destroy" { - type = bool - description = "Delete the virtual machine afer exporting to the content library." - default = true -} - -// Removable Media Settings - -variable "common_iso_datastore" { - type = string - description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')" -} - -variable "common_iso_path" { - type = string - description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')" -} - -variable "common_iso_hash" { - type = string - description = "The algorithm used for the checkcum of the ISO image. (e.g. sha512')" -} - -variable "iso_file" { - type = string - description = "The file name of the ISO image. (e.g. 'iso-windows-server-2019.iso')" -} - -variable "iso_checksum" { - type = string - description = "The checksum of the ISO image. (e.g. Result of 'shasum -a 512 iso-windows-server-2019.iso')" -} - -// Boot Settings - -variable "common_http_port_min" { - type = number - description = "The start of the HTTP port range." -} - -variable "common_http_port_max" { - type = number - description = "The end of the HTTP port range." -} - -variable "vm_boot_order" { - type = string - description = "The time to wait before boot." - default = "disk,cdrom" -} - -variable "vm_boot_wait" { - type = string - description = "The boot order for virtual machines devices." -} - -variable "vm_boot_command" { - type = list(string) - description = "The virtual machine boot command." - default = [] -} - -variable "vm_shutdown_command" { - type = string - description = "Command(s) for guest operating system shutdown." -} - -variable "common_ip_wait_timeout" { - type = string - description = "Time to wait for guest operating system IP address response." -} - -variable "common_shutdown_timeout" { - type = string - description = "Time to wait for guest operating system shutdown." -} - -// Communicator Settings and Credentials - -variable "build_username" { - type = string - description = "The username to login to the guest operating system. (e.g. rainpole)" - sensitive = true -} - -variable "build_password" { - type = string - description = "The password to login to the guest operating system." - sensitive = true -} - -variable "build_password_encrypted" { - type = string - description = "The encrypted password for building the guest operating system." - sensitive = true - default = "" -} - -variable "build_key" { - type = string - description = "The public key to login to the guest operating system." - sensitive = true - default = "" -} - -// Communicator Credentials - -variable "communicator_port" { - type = string - description = "The port for the communicator protocol." -} - -variable "communicator_timeout" { - type = string - description = "The timeout for the communicator protocol." -} - -// Provisioner Settings - -variable "scripts" { - type = list(string) - description = "A list of scripts and their relative paths to transfer and execute." - default = [] -} - -variable "inline" { - type = list(string) - description = "A list of commands to execute." - default = [] -} - // BLOCK: locals // Defines the local variables. @@ -411,9 +76,9 @@ source "vsphere-iso" "windows-server-standard-core" { cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -487,9 +152,9 @@ source "vsphere-iso" "windows-server-standard-dexp" { cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -563,9 +228,9 @@ source "vsphere-iso" "windows-server-datacenter-core" { cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -639,9 +304,9 @@ source "vsphere-iso" "windows-server-datacenter-dexp" { cd_files = [ "../../../scripts/${var.vm_guest_os_family}/", "../../../certificates/" - ] + ] cd_content = { - "autounattend.xml" = templatefile("cd/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 }) + "autounattend.xml" = templatefile("${path.cwd}/cd/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 @@ -690,15 +355,15 @@ build { environment_vars = [ "BUILD_USERNAME=${var.build_username}" ] - elevated_user = var.build_username - elevated_password = var.build_password - scripts = var.scripts + elevated_user = var.build_username + elevated_password = var.build_password + scripts = var.scripts } provisioner "powershell" { - elevated_user = var.build_username - elevated_password = var.build_password - inline = var.inline + elevated_user = var.build_username + elevated_password = var.build_password + inline = var.inline } provisioner "windows-update" { @@ -715,7 +380,7 @@ build { } post-processor "manifest" { - output = "../../../manifests/${local.buildtime}-${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}.json" + output = "${path.cwd}/output/${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/manifests/PLACEHOLDER.md b/manifests/PLACEHOLDER.md deleted file mode 100644 index d92065db5..000000000 --- a/manifests/PLACEHOLDER.md +++ /dev/null @@ -1 +0,0 @@ -This is just a placeholder file.