diff --git a/CHANGELOG.md b/CHANGELOG.md index 39c86e136..9f8c62ebb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ * Adds CentOS 9 Stream. * Adds Rocky Linux 9. * Adds AlmaLinux OS 9. -* Adds options for setting the number of video displays and the size for the video memory for both Windows 11 and 10, which is useful for virtual desktop use cases (_e.g._, Horizon). The ability to set the number of displays was added in `v1.0.6` of `packer-plugin-vsphere`. +* Adds option for setting the number of video displays and the size for the video memory for both Windows 11 and 10, which is useful for virtual desktop use cases (_e.g._, Horizon). The ability to set the number of displays was added in `v1.0.6` of `packer-plugin-vsphere`. +* Adds a common option to export machine image artifacts (`.ovf`,`.vmdk`, and `.mf`) to an output path. * Removes the default requirement for a trusted root authority certificate to be imported and trusted by each machine image build. This will allow project users to get started more quickly without a pre-requisite. 🛠️ **Refactor**: diff --git a/README.md b/README.md index 87152a4da..fc23a9231 100644 --- a/README.md +++ b/README.md @@ -360,6 +360,7 @@ The directory structure of the repository. │ │ └── main.yml │ ├── ansible.cfg │ └── main.yml +├── artifacts ├── builds │ ├── ansible.pkvars.hcl.example │ ├── build.pkvars.hcl.example @@ -392,11 +393,12 @@ The directory structure of the repository. The files are distributed in the following directories. -* **`ansible`** - contains the Ansible roles to prepare a Linux machine image build. -* **`builds`** - contains the templates, variables, and configuration files for the machine image build. -* **`scripts`** - contains the scripts to initialize and prepare a Windows machine image build. -* **`manifests`** - manifests created after the completion of the machine image build. -* **`terraform`** - contains example Terraform plans to test machine image builds. +* **`ansible`** - contains the Ansible roles to prepare Linux machine image builds. +* **`artifacts`** - contains the OVF artifacts created by the builds, if enabled. +* **`builds`** - contains the templates, variables, and configuration files for the machine image builds. +* **`scripts`** - contains the scripts to initialize and prepare Windows machine image builds. +* **`manifests`** - manifests created after the completion of the machine image builds. +* **`terraform`** - contains example Terraform plans to create a custom role and test machine image builds. > **Warning** > @@ -608,7 +610,7 @@ Generate a SHA-512 encrypted password for the `build_password_encrypted` using t ```console rainpole@photon> sudo systemctl start docker -rainpole@photon> sudo docker run -it --rm alpine:latest +rainpole@photon> sudo docker run -it --rm alpine:latest mkpasswd -m sha512 Password: *************** [password hash] @@ -618,7 +620,7 @@ rainpole@photon> sudo systemctl stop docker **Example**: mkpasswd using Docker on macOS: ```console -rainpole@macos> docker run -it --rm alpine:latest +rainpole@macos> docker run -it --rm alpine:latest mkpasswd -m sha512 Password: *************** [password hash] @@ -627,7 +629,7 @@ Password: *************** **Example**: mkpasswd on Ubuntu: ```console -rainpole@ubuntu> mkpasswd -m sha-512 +rainpole@ubuntu> mkpasswd -m sha-512 Password: *************** [password hash] ``` @@ -685,6 +687,7 @@ Edit the `config/common.pkvars.hcl` file to configure the following common varia * Virtual Machine Settings * Template and Content Library Settings +* OVF Export Settings * Removable Media Settings * Boot and Provisioning Settings @@ -702,6 +705,10 @@ common_content_library_name = "sfo-w01-lib01" common_content_library_ovf = true common_content_library_destroy = true +// OVF Export Settings +common_ovf_export_enabled = false +common_ovf_export_overwrite = true + // Removable Media Settings common_iso_datastore = "sfo-w01-cl01-ds-nfs01" diff --git a/artifacts/.gitkeep b/artifacts/.gitkeep new file mode 100644 index 000000000..d3f5a12fa --- /dev/null +++ b/artifacts/.gitkeep @@ -0,0 +1 @@ + diff --git a/builds/common.pkrvars.hcl.example b/builds/common.pkrvars.hcl.example index 925dcca36..6e5a3d9c7 100644 --- a/builds/common.pkrvars.hcl.example +++ b/builds/common.pkrvars.hcl.example @@ -16,6 +16,10 @@ common_content_library_ovf = true common_content_library_destroy = true common_content_library_skip_export = false +// OVF Export Settings +common_ovf_export_enabled = false +common_ovf_export_overwrite = true + // Removable Media Settings common_iso_datastore = "sfo-w01-cl01-ds-nfs01" @@ -25,4 +29,4 @@ common_http_ip = null common_http_port_min = 8000 common_http_port_max = 8099 common_ip_wait_timeout = "20m" -common_shutdown_timeout = "15m" \ No newline at end of file +common_shutdown_timeout = "15m" diff --git a/builds/linux/almalinux/8/linux-almalinux.pkr.hcl b/builds/linux/almalinux/8/linux-almalinux.pkr.hcl index ffbef98fb..0202b5a57 100644 --- a/builds/linux/almalinux/8/linux-almalinux.pkr.hcl +++ b/builds/linux/almalinux/8/linux-almalinux.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -131,6 +132,19 @@ source "vsphere-iso" "linux-almalinux" { } } + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } + } // BLOCK: build diff --git a/builds/linux/almalinux/8/variables.pkr.hcl b/builds/linux/almalinux/8/variables.pkr.hcl index 55d2f79a1..4ea9f8202 100644 --- a/builds/linux/almalinux/8/variables.pkr.hcl +++ b/builds/linux/almalinux/8/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/linux/almalinux/9/linux-almalinux.pkr.hcl b/builds/linux/almalinux/9/linux-almalinux.pkr.hcl index ce401f02c..1443dab37 100644 --- a/builds/linux/almalinux/9/linux-almalinux.pkr.hcl +++ b/builds/linux/almalinux/9/linux-almalinux.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -130,6 +131,19 @@ source "vsphere-iso" "linux-almalinux" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/almalinux/9/variables.pkr.hcl b/builds/linux/almalinux/9/variables.pkr.hcl index 238c7cf70..4d99758df 100644 --- a/builds/linux/almalinux/9/variables.pkr.hcl +++ b/builds/linux/almalinux/9/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/linux/centos/7/linux-centos.pkr.hcl b/builds/linux/centos/7/linux-centos.pkr.hcl index 1e4daa0fe..2e0175d73 100644 --- a/builds/linux/centos/7/linux-centos.pkr.hcl +++ b/builds/linux/centos/7/linux-centos.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -130,6 +131,19 @@ source "vsphere-iso" "linux-centos" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/centos/7/variables.pkr.hcl b/builds/linux/centos/7/variables.pkr.hcl index 1d4f52749..f0bece1c7 100644 --- a/builds/linux/centos/7/variables.pkr.hcl +++ b/builds/linux/centos/7/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/linux/centos/8-stream/linux-centos-stream.pkr.hcl b/builds/linux/centos/8-stream/linux-centos-stream.pkr.hcl index dfee019a0..ce42e815b 100644 --- a/builds/linux/centos/8-stream/linux-centos-stream.pkr.hcl +++ b/builds/linux/centos/8-stream/linux-centos-stream.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -130,6 +131,19 @@ source "vsphere-iso" "linux-centos-stream" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/centos/8-stream/variables.pkr.hcl b/builds/linux/centos/8-stream/variables.pkr.hcl index 3ef484178..ba318dfd7 100644 --- a/builds/linux/centos/8-stream/variables.pkr.hcl +++ b/builds/linux/centos/8-stream/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/linux/centos/9-stream/linux-centos-stream.pkr.hcl b/builds/linux/centos/9-stream/linux-centos-stream.pkr.hcl index 6a03e9f1f..cad58dd9b 100644 --- a/builds/linux/centos/9-stream/linux-centos-stream.pkr.hcl +++ b/builds/linux/centos/9-stream/linux-centos-stream.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -130,6 +131,19 @@ source "vsphere-iso" "linux-centos-stream" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/centos/9-stream/variables.pkr.hcl b/builds/linux/centos/9-stream/variables.pkr.hcl index 6a2e9ca0e..1c4b2caad 100644 --- a/builds/linux/centos/9-stream/variables.pkr.hcl +++ b/builds/linux/centos/9-stream/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/linux/photon/4/linux-photon.pkr.hcl b/builds/linux/photon/4/linux-photon.pkr.hcl index 3236c7d33..51f19f0c9 100644 --- a/builds/linux/photon/4/linux-photon.pkr.hcl +++ b/builds/linux/photon/4/linux-photon.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.json" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -128,6 +129,19 @@ source "vsphere-iso" "linux-photon" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/photon/4/variables.pkr.hcl b/builds/linux/photon/4/variables.pkr.hcl index a84e39953..51145f3f9 100644 --- a/builds/linux/photon/4/variables.pkr.hcl +++ b/builds/linux/photon/4/variables.pkr.hcl @@ -191,6 +191,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { @@ -335,4 +349,4 @@ variable "ansible_key" { type = string description = "The public key for Ansible to login to the guest operating system." sensitive = true -} \ No newline at end of file +} diff --git a/builds/linux/rhel/7/linux-rhel.pkr.hcl b/builds/linux/rhel/7/linux-rhel.pkr.hcl index 477bb7c77..d65ad6e76 100644 --- a/builds/linux/rhel/7/linux-rhel.pkr.hcl +++ b/builds/linux/rhel/7/linux-rhel.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -132,6 +133,19 @@ source "vsphere-iso" "linux-rhel" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/rhel/7/variables.pkr.hcl b/builds/linux/rhel/7/variables.pkr.hcl index aa67ce861..3fed314f2 100644 --- a/builds/linux/rhel/7/variables.pkr.hcl +++ b/builds/linux/rhel/7/variables.pkr.hcl @@ -223,6 +223,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/linux/rhel/8/linux-rhel.pkr.hcl b/builds/linux/rhel/8/linux-rhel.pkr.hcl index f29f57682..10ad8dcd7 100644 --- a/builds/linux/rhel/8/linux-rhel.pkr.hcl +++ b/builds/linux/rhel/8/linux-rhel.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -132,6 +133,19 @@ source "vsphere-iso" "linux-rhel" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/rhel/8/variables.pkr.hcl b/builds/linux/rhel/8/variables.pkr.hcl index 2a80b017d..394812b12 100644 --- a/builds/linux/rhel/8/variables.pkr.hcl +++ b/builds/linux/rhel/8/variables.pkr.hcl @@ -223,6 +223,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { @@ -367,4 +381,4 @@ variable "ansible_key" { type = string description = "The public key for Ansible to login to the guest operating system." sensitive = true -} \ No newline at end of file +} diff --git a/builds/linux/rhel/9/linux-rhel.pkr.hcl b/builds/linux/rhel/9/linux-rhel.pkr.hcl index 9edb58d94..c3a6a83fc 100644 --- a/builds/linux/rhel/9/linux-rhel.pkr.hcl +++ b/builds/linux/rhel/9/linux-rhel.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -132,6 +133,19 @@ source "vsphere-iso" "linux-rhel" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/rhel/9/variables.pkr.hcl b/builds/linux/rhel/9/variables.pkr.hcl index 4f9b4e3ce..832d17515 100644 --- a/builds/linux/rhel/9/variables.pkr.hcl +++ b/builds/linux/rhel/9/variables.pkr.hcl @@ -223,6 +223,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/linux/rocky/8/linux-rocky.pkr.hcl b/builds/linux/rocky/8/linux-rocky.pkr.hcl index cc4f9e1a9..742e368ff 100644 --- a/builds/linux/rocky/8/linux-rocky.pkr.hcl +++ b/builds/linux/rocky/8/linux-rocky.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -130,6 +131,19 @@ source "vsphere-iso" "linux-rocky" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/rocky/8/variables.pkr.hcl b/builds/linux/rocky/8/variables.pkr.hcl index 026aabfa8..6af5df996 100644 --- a/builds/linux/rocky/8/variables.pkr.hcl +++ b/builds/linux/rocky/8/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/linux/rocky/9/linux-rocky.pkr.hcl b/builds/linux/rocky/9/linux-rocky.pkr.hcl index 54df65358..14058fb5f 100644 --- a/builds/linux/rocky/9/linux-rocky.pkr.hcl +++ b/builds/linux/rocky/9/linux-rocky.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -130,6 +131,19 @@ source "vsphere-iso" "linux-rocky" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/rocky/9/variables.pkr.hcl b/builds/linux/rocky/9/variables.pkr.hcl index 3d38ce70f..9958f6da8 100644 --- a/builds/linux/rocky/9/variables.pkr.hcl +++ b/builds/linux/rocky/9/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/linux/ubuntu/18-04-lts/linux-ubuntu.pkr.hcl b/builds/linux/ubuntu/18-04-lts/linux-ubuntu.pkr.hcl index ab7de6402..a040be21d 100644 --- a/builds/linux/ubuntu/18-04-lts/linux-ubuntu.pkr.hcl +++ b/builds/linux/ubuntu/18-04-lts/linux-ubuntu.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { build_username = var.build_username @@ -137,6 +138,19 @@ source "vsphere-iso" "linux-ubuntu" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/ubuntu/18-04-lts/variables.pkr.hcl b/builds/linux/ubuntu/18-04-lts/variables.pkr.hcl index 4a0d7159f..f1551b030 100644 --- a/builds/linux/ubuntu/18-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu/18-04-lts/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { @@ -353,4 +367,4 @@ variable "ansible_key" { type = string description = "The public key for Ansible to login to the guest operating system." sensitive = true -} \ No newline at end of file +} diff --git a/builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl b/builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl index 29d6e4fee..779f5960d 100644 --- a/builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl +++ b/builds/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/meta-data" = file("${abspath(path.root)}/data/meta-data") "/user-data" = templatefile("${abspath(path.root)}/data/user-data.pkrtpl.hcl", { @@ -134,6 +135,19 @@ source "vsphere-iso" "linux-ubuntu" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/ubuntu/20-04-lts/variables.pkr.hcl b/builds/linux/ubuntu/20-04-lts/variables.pkr.hcl index ff6b82323..0b4b88bec 100644 --- a/builds/linux/ubuntu/20-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu/20-04-lts/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { @@ -353,4 +367,4 @@ variable "ansible_key" { type = string description = "The public key for Ansible to login to the guest operating system." sensitive = true -} \ No newline at end of file +} diff --git a/builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkr.hcl b/builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkr.hcl index b3b31d5ca..22b905785 100644 --- a/builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkr.hcl +++ b/builds/linux/ubuntu/22-04-lts/linux-ubuntu.pkr.hcl @@ -29,6 +29,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/meta-data" = file("${abspath(path.root)}/data/meta-data") "/user-data" = templatefile("${abspath(path.root)}/data/user-data.pkrtpl.hcl", { @@ -134,6 +135,19 @@ source "vsphere-iso" "linux-ubuntu" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/linux/ubuntu/22-04-lts/variables.pkr.hcl b/builds/linux/ubuntu/22-04-lts/variables.pkr.hcl index 0e07f07f5..b1c3fe30d 100644 --- a/builds/linux/ubuntu/22-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu/22-04-lts/variables.pkr.hcl @@ -209,6 +209,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { @@ -353,4 +367,4 @@ variable "ansible_key" { type = string description = "The public key for Ansible to login to the guest operating system." sensitive = true -} \ No newline at end of file +} diff --git a/builds/windows/desktop/10/variables.pkr.hcl b/builds/windows/desktop/10/variables.pkr.hcl index d92826113..2b6506d51 100644 --- a/builds/windows/desktop/10/variables.pkr.hcl +++ b/builds/windows/desktop/10/variables.pkr.hcl @@ -250,6 +250,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/windows/desktop/10/windows.pkr.hcl b/builds/windows/desktop/10/windows.pkr.hcl index b4d2a9ab4..638214803 100644 --- a/builds/windows/desktop/10/windows.pkr.hcl +++ b/builds/windows/desktop/10/windows.pkr.hcl @@ -35,6 +35,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${var.vm_guest_os_edition}-v${local.build_version}" } @@ -130,6 +131,19 @@ source "vsphere-iso" "windows-desktop" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/windows/desktop/11/variables.pkr.hcl b/builds/windows/desktop/11/variables.pkr.hcl index ab6e80fa5..14063451e 100644 --- a/builds/windows/desktop/11/variables.pkr.hcl +++ b/builds/windows/desktop/11/variables.pkr.hcl @@ -256,6 +256,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { diff --git a/builds/windows/desktop/11/windows.pkr.hcl b/builds/windows/desktop/11/windows.pkr.hcl index c25e23431..aac794550 100644 --- a/builds/windows/desktop/11/windows.pkr.hcl +++ b/builds/windows/desktop/11/windows.pkr.hcl @@ -35,6 +35,7 @@ locals { manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${var.vm_guest_os_edition}-v${local.build_version}" } @@ -132,6 +133,19 @@ source "vsphere-iso" "windows-desktop" { # skip_import = var.common_content_library_skip_export # } # } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = local.ovf_export_path + } + } } // BLOCK: build diff --git a/builds/windows/server/2019/variables.pkr.hcl b/builds/windows/server/2019/variables.pkr.hcl index 995707375..153f0ddbb 100644 --- a/builds/windows/server/2019/variables.pkr.hcl +++ b/builds/windows/server/2019/variables.pkr.hcl @@ -277,6 +277,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { @@ -411,4 +425,4 @@ variable "inline" { type = list(string) description = "A list of commands to run." default = [] -} \ No newline at end of file +} diff --git a/builds/windows/server/2019/windows-server.pkr.hcl b/builds/windows/server/2019/windows-server.pkr.hcl index 5addaa296..09ce6df17 100644 --- a/builds/windows/server/2019/windows-server.pkr.hcl +++ b/builds/windows/server/2019/windows-server.pkr.hcl @@ -34,6 +34,8 @@ locals { iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" + manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/" vm_name_datacenter_core = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${var.vm_guest_os_edition_datacenter}-${var.vm_guest_os_experience_core}-v${local.build_version}" vm_name_datacenter_desktop = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${var.vm_guest_os_edition_datacenter}-${var.vm_guest_os_experience_desktop}-v${local.build_version}" vm_name_standard_core = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${var.vm_guest_os_edition_standard}-${var.vm_guest_os_experience_core}-v${local.build_version}" @@ -130,6 +132,19 @@ source "vsphere-iso" "windows-server-standard-core" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name_standard_core + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = "${local.ovf_export_path}/${local.vm_name_standard_core}" + } + } } source "vsphere-iso" "windows-server-standard-desktop" { @@ -220,6 +235,19 @@ source "vsphere-iso" "windows-server-standard-desktop" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name_standard_desktop + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = "${local.ovf_export_path}/${local.vm_name_standard_desktop}" + } + } } source "vsphere-iso" "windows-server-datacenter-core" { @@ -312,6 +340,19 @@ source "vsphere-iso" "windows-server-datacenter-core" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name_datacenter_core + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = "${local.ovf_export_path}/${local.vm_inst_os_image_datacenter_core}" + } + } } source "vsphere-iso" "windows-server-datacenter-desktop" { @@ -402,6 +443,19 @@ source "vsphere-iso" "windows-server-datacenter-desktop" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name_datacenter_desktop + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = "${local.ovf_export_path}/${local.vm_name_datacenter_desktop}" + } + } } // BLOCK: build diff --git a/builds/windows/server/2022/variables.pkr.hcl b/builds/windows/server/2022/variables.pkr.hcl index a2f3ba8c5..6361ca982 100644 --- a/builds/windows/server/2022/variables.pkr.hcl +++ b/builds/windows/server/2022/variables.pkr.hcl @@ -277,6 +277,20 @@ variable "common_content_library_skip_export" { default = false } +// OVF Export Settings + +variable "common_ovf_export_enabled" { + type = bool + description = "Enable OVF artifact export." + default = false +} + +variable "common_ovf_export_overwrite" { + type = bool + description = "Overwrite existing OVF artifact." + default = true +} + // Removable Media Settings variable "common_iso_datastore" { @@ -411,4 +425,4 @@ variable "inline" { type = list(string) description = "A list of commands to run." default = [] -} \ No newline at end of file +} diff --git a/builds/windows/server/2022/windows-server.pkr.hcl b/builds/windows/server/2022/windows-server.pkr.hcl index ddeba4e78..d756435bc 100644 --- a/builds/windows/server/2022/windows-server.pkr.hcl +++ b/builds/windows/server/2022/windows-server.pkr.hcl @@ -34,6 +34,8 @@ locals { iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) manifest_path = "${path.cwd}/manifests/" + manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/" vm_name_datacenter_core = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${var.vm_guest_os_edition_datacenter}-${var.vm_guest_os_experience_core}-v${local.build_version}" vm_name_datacenter_desktop = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${var.vm_guest_os_edition_datacenter}-${var.vm_guest_os_experience_desktop}-v${local.build_version}" vm_name_standard_core = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${var.vm_guest_os_edition_standard}-${var.vm_guest_os_experience_core}-v${local.build_version}" @@ -130,6 +132,19 @@ source "vsphere-iso" "windows-server-standard-core" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name_standard_core + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = "${local.ovf_export_path}/${local.vm_name_standard_core}" + } + } } source "vsphere-iso" "windows-server-standard-desktop" { @@ -220,6 +235,19 @@ source "vsphere-iso" "windows-server-standard-desktop" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name_standard_desktop + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = "${local.ovf_export_path}/${local.vm_name_standard_desktop}" + } + } } source "vsphere-iso" "windows-server-datacenter-core" { @@ -312,6 +340,19 @@ source "vsphere-iso" "windows-server-datacenter-core" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name_datacenter_core + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = "${local.ovf_export_path}/${local.vm_name_datacenter_core}" + } + } } source "vsphere-iso" "windows-server-datacenter-desktop" { @@ -402,6 +443,19 @@ source "vsphere-iso" "windows-server-datacenter-desktop" { skip_import = var.common_content_library_skip_export } } + + // OVF Export Settings + dynamic "export" { + for_each = var.common_ovf_export_enabled == true ? [1] : [] + content { + name = local.vm_name_datacenter_desktop + force = var.common_ovf_export_overwrite + options = [ + "extraconfig" + ] + output_directory = "${local.ovf_export_path}/${local.vm_name_datacenter_desktop}" + } + } } // BLOCK: build diff --git a/set-envvars.sh b/set-envvars.sh index 3d7fc5ccd..749cd7b6e 100755 --- a/set-envvars.sh +++ b/set-envvars.sh @@ -17,6 +17,8 @@ common_template_conversion="false" common_content_library_ovf="true" common_content_library_destroy="true" common_content_library_skip_export="false" +common_ovf_export_enabled="false" +common_ovf_export_overwrite="true" common_data_source="http" common_http_ip="" common_http_port_min="8000" @@ -69,6 +71,10 @@ read -r -p "Convert to a template (recommended: ""${common_template_conversion}" read -r -p "Export OVF Template to the content library (recommended: ""${common_content_library_ovf}""): " common_content_library_ovf read -r -p "Destroy virtual machine artifact (recommended: ""${common_content_library_destroy}""): " common_content_library_destroy read -r -p "Skip export to content library (recommended: ""${common_content_library_skip_export}""): " common_content_library_skip_export +echo -e '\n> Set the common OVF export settings.' +# OVF Export Settings +read -r -p "Export as an OVF artifact (recommended: ""${common_ovf_export_enabled}""): " common_ovf_export_enabled +read -r -p "Overwrite an existing OVF artifact (recommended: ""${common_ovf_export_overwrite}""): " common_ovf_export_overwrite echo -e '\n> Set the common boot and provisioning settings.' # Boot and Provisioning Settings read -r -p "Set the provisioning datasource (recommended: ""${common_data_source}""): " common_data_source @@ -149,6 +155,11 @@ export PKR_VAR_common_content_library_ovf="${common_content_library_ovf}" export PKR_VAR_common_content_library_destroy="${common_content_library_destroy}" export PKR_VAR_common_content_library_skip_export="${common_content_library_skip_export}" +echo '> Setting the OVF export settings...' +# OVF Export Settings +export PKR_VAR_common_ovf_export_enabled="${common_ovf_export_enabled}" +export PKR_VAR_common_ovf_export_overwrite="${common_ovf_export_overwrite}" + echo '> Setting the common boot and provisioning settings...' # Boot and Provisioning Settings export PKR_VAR_common_data_source="${common_data_source}" @@ -224,6 +235,11 @@ case $display_environmental_variables in echo - PKR_VAR_common_content_library_destroy: "$PKR_VAR_common_content_library_destroy" echo - PKR_VAR_common_content_library_skip_export: "$PKR_VAR_common_content_library_skip_export" + # OVF Export Settings + echo -e '\nOVF Export Settings' + echo - PKR_VAR_common_ovf_export_enabled: "$PKR_VAR_common_ovf_export_enabled" + echo - PKR_VAR_common_ovf_export_overwrite: "$PKR_VAR_common_ovf_export_overwrite" + # Boot and Provisioning Settings echo -e '\nBoot and Provisioning Settings' echo - PKR_VAR_common_data_source: "$PKR_VAR_common_data_source"