From bb204a5cf18a17c41a528889c07838cd65c0027c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Este-Gracias?= Date: Tue, 21 Sep 2021 18:26:00 +0200 Subject: [PATCH] Optional content_library_destination block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Este-Gracias --- .../linux/almalinux-8/linux-almalinux.pkr.hcl | 13 ++++-- builds/linux/almalinux-8/variables.pkr.hcl | 3 +- .../centos-linux-8/linux-centos-linux.pkr.hcl | 13 ++++-- builds/linux/centos-linux-8/variables.pkr.hcl | 3 +- .../linux-centos-stream.pkr.hcl | 13 ++++-- .../linux/centos-stream-8/variables.pkr.hcl | 3 +- builds/linux/photon-4/linux-photon.pkr.hcl | 15 +++--- builds/linux/photon-4/variables.pkr.hcl | 3 +- .../redhat-linux-8/linux-redhat-linux.pkr.hcl | 13 ++++-- builds/linux/redhat-linux-8/variables.pkr.hcl | 3 +- .../rocky-linux-8/linux-rocky-linux.pkr.hcl | 13 ++++-- builds/linux/rocky-linux-8/variables.pkr.hcl | 3 +- .../linux-ubuntu-server.pkr.hcl | 13 ++++-- .../ubuntu-server-18-04-lts/variables.pkr.hcl | 3 +- .../linux-ubuntu-server.pkr.hcl | 13 ++++-- .../ubuntu-server-20-04-lts/variables.pkr.hcl | 3 +- .../windows-server-2016/variables.pkr.hcl | 3 +- .../windows-server.pkr.hcl | 46 ++++++++++++------- .../windows-server-2019/variables.pkr.hcl | 3 +- .../windows-server.pkr.hcl | 46 ++++++++++++------- .../windows-server-2022/variables.pkr.hcl | 3 +- .../windows-server.pkr.hcl | 46 ++++++++++++------- 22 files changed, 174 insertions(+), 103 deletions(-) diff --git a/builds/linux/almalinux-8/linux-almalinux.pkr.hcl b/builds/linux/almalinux-8/linux-almalinux.pkr.hcl index c9f83a89e..4c6fc4b42 100644 --- a/builds/linux/almalinux-8/linux-almalinux.pkr.hcl +++ b/builds/linux/almalinux-8/linux-almalinux.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: AlmaLinux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -90,10 +90,13 @@ source "vsphere-iso" "linux-almalinux" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } diff --git a/builds/linux/almalinux-8/variables.pkr.hcl b/builds/linux/almalinux-8/variables.pkr.hcl index 545074a79..495063c99 100644 --- a/builds/linux/almalinux-8/variables.pkr.hcl +++ b/builds/linux/almalinux-8/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: AlmaLinux 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -193,6 +193,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl b/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl index 42560c98d..59bb24fa0 100644 --- a/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl +++ b/builds/linux/centos-linux-8/linux-centos-linux.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: CentOS Linux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -90,10 +90,13 @@ source "vsphere-iso" "linux-centos-linux" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } diff --git a/builds/linux/centos-linux-8/variables.pkr.hcl b/builds/linux/centos-linux-8/variables.pkr.hcl index df4c61b6f..c33c256ec 100644 --- a/builds/linux/centos-linux-8/variables.pkr.hcl +++ b/builds/linux/centos-linux-8/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: CentOS Linux 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -193,6 +193,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl b/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl index b44abbc3e..841a1e354 100644 --- a/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl +++ b/builds/linux/centos-stream-8/linux-centos-stream.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: CentOS Stream 8 template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -90,10 +90,13 @@ source "vsphere-iso" "linux-centos-stream" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } diff --git a/builds/linux/centos-stream-8/variables.pkr.hcl b/builds/linux/centos-stream-8/variables.pkr.hcl index 98a6f4c49..93499ebc9 100644 --- a/builds/linux/centos-stream-8/variables.pkr.hcl +++ b/builds/linux/centos-stream-8/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: CentOS Stream 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -193,6 +193,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/linux/photon-4/linux-photon.pkr.hcl b/builds/linux/photon-4/linux-photon.pkr.hcl index 307501cc5..43432be69 100644 --- a/builds/linux/photon-4/linux-photon.pkr.hcl +++ b/builds/linux/photon-4/linux-photon.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: VMware Photon OS 4 template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -91,10 +91,13 @@ source "vsphere-iso" "linux-photon" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -108,7 +111,7 @@ build { 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 = [ diff --git a/builds/linux/photon-4/variables.pkr.hcl b/builds/linux/photon-4/variables.pkr.hcl index 59bed1388..8dcbaea21 100644 --- a/builds/linux/photon-4/variables.pkr.hcl +++ b/builds/linux/photon-4/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: VMware Photon OS 4 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -175,6 +175,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl b/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl index 94532fe78..cd64b8e24 100644 --- a/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl +++ b/builds/linux/redhat-linux-8/linux-redhat-linux.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Red Hat Enterprise Linux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -90,10 +90,13 @@ source "vsphere-iso" "linux-redhat-linux" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } diff --git a/builds/linux/redhat-linux-8/variables.pkr.hcl b/builds/linux/redhat-linux-8/variables.pkr.hcl index 30dda6cf1..407114382 100644 --- a/builds/linux/redhat-linux-8/variables.pkr.hcl +++ b/builds/linux/redhat-linux-8/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Red Hat Enterprise Linux 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -207,6 +207,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl b/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl index 38cb99eab..113e09832 100644 --- a/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl +++ b/builds/linux/rocky-linux-8/linux-rocky-linux.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Rocky Linux 8 template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -90,10 +90,13 @@ source "vsphere-iso" "linux-rocky-linux" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } diff --git a/builds/linux/rocky-linux-8/variables.pkr.hcl b/builds/linux/rocky-linux-8/variables.pkr.hcl index d63648d20..b4080a32d 100644 --- a/builds/linux/rocky-linux-8/variables.pkr.hcl +++ b/builds/linux/rocky-linux-8/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Rocky Linux 8 variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -193,6 +193,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl index 489c77f94..1a847107b 100644 --- a/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl +++ b/builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Ubuntu Server 18.04 LTS template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -103,10 +103,13 @@ source "vsphere-iso" "linux-ubuntu-server" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } diff --git a/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl b/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl index af7d59516..fbe820148 100644 --- a/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu-server-18-04-lts/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Ubuntu Server 18.04 LTS variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -193,6 +193,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl index f06ba7111..d51817cf3 100644 --- a/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/linux-ubuntu-server.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Ubuntu Server 20.04 LTS template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -91,10 +91,13 @@ source "vsphere-iso" "linux-ubuntu-server" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } diff --git a/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl b/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl index 36598b7a6..2afa11991 100644 --- a/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl +++ b/builds/linux/ubuntu-server-20-04-lts/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Ubuntu Server 20.04 LTS variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -193,6 +193,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/windows/windows-server-2016/variables.pkr.hcl b/builds/windows/windows-server-2016/variables.pkr.hcl index 64d84845a..cb827c880 100644 --- a/builds/windows/windows-server-2016/variables.pkr.hcl +++ b/builds/windows/windows-server-2016/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Microsoft Windows Server 2016 Standard variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -217,6 +217,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/windows/windows-server-2016/windows-server.pkr.hcl b/builds/windows/windows-server-2016/windows-server.pkr.hcl index 34fb341f5..92f4f2c2f 100644 --- a/builds/windows/windows-server-2016/windows-server.pkr.hcl +++ b/builds/windows/windows-server-2016/windows-server.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Microsoft Windows Server 2016 Standard template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -100,10 +100,13 @@ source "vsphere-iso" "windows-server-standard-core" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -175,10 +178,13 @@ source "vsphere-iso" "windows-server-standard-dexp" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -251,10 +257,13 @@ source "vsphere-iso" "windows-server-datacenter-core" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -327,10 +336,13 @@ source "vsphere-iso" "windows-server-datacenter-dexp" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } diff --git a/builds/windows/windows-server-2019/variables.pkr.hcl b/builds/windows/windows-server-2019/variables.pkr.hcl index 3a6df7103..be46682b6 100644 --- a/builds/windows/windows-server-2019/variables.pkr.hcl +++ b/builds/windows/windows-server-2019/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Microsoft Windows Server 2019 Standard variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -217,6 +217,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/windows/windows-server-2019/windows-server.pkr.hcl b/builds/windows/windows-server-2019/windows-server.pkr.hcl index ab7a9ab9e..50e34ea73 100644 --- a/builds/windows/windows-server-2019/windows-server.pkr.hcl +++ b/builds/windows/windows-server-2019/windows-server.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Microsoft Windows Server 2019 Standard template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -100,10 +100,13 @@ source "vsphere-iso" "windows-server-standard-core" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -176,10 +179,13 @@ source "vsphere-iso" "windows-server-standard-dexp" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -252,10 +258,13 @@ source "vsphere-iso" "windows-server-datacenter-core" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -328,10 +337,13 @@ source "vsphere-iso" "windows-server-datacenter-dexp" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } diff --git a/builds/windows/windows-server-2022/variables.pkr.hcl b/builds/windows/windows-server-2022/variables.pkr.hcl index f5804d145..6c1c924df 100644 --- a/builds/windows/windows-server-2022/variables.pkr.hcl +++ b/builds/windows/windows-server-2022/variables.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Microsoft Windows Server 2022 Standard variables using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -217,6 +217,7 @@ variable "common_template_conversion" { variable "common_content_library_name" { type = string description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')" + default = null } variable "common_content_library_ovf" { diff --git a/builds/windows/windows-server-2022/windows-server.pkr.hcl b/builds/windows/windows-server-2022/windows-server.pkr.hcl index 1125d0348..77e9b0cb4 100644 --- a/builds/windows/windows-server-2022/windows-server.pkr.hcl +++ b/builds/windows/windows-server-2022/windows-server.pkr.hcl @@ -1,5 +1,5 @@ /* - DESCRIPTION: + DESCRIPTION: Microsoft Windows Server 2022 Standard template using the Packer Builder for VMware vSphere (vsphere-iso). */ @@ -100,10 +100,13 @@ source "vsphere-iso" "windows-server-standard-core" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -176,10 +179,13 @@ source "vsphere-iso" "windows-server-standard-dexp" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -252,10 +258,13 @@ source "vsphere-iso" "windows-server-datacenter-core" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } } @@ -328,10 +337,13 @@ source "vsphere-iso" "windows-server-datacenter-dexp" { // 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 + dynamic "content_library_destination" { + for_each = var.common_content_library_name != null ? [1] : [] + content { + library = var.common_content_library_name + ovf = var.common_content_library_ovf + destroy = var.common_content_library_destroy + } } }