Fix packer validation error when cloud_network variable is not set.
Issue:
- builder.pkr.hcl: cloud_network variable had no default value
- Both templates: networks parameter required array, failed with null
Changes:
1. Added 'default = null' to cloud_network variable in builder.pkr.hcl
2. Made networks parameter conditional in both templates:
- If cloud_network is null: networks = null (uses OpenStack default)
- If cloud_network is set: networks = [cloud_network]
Error Fixed:
Error: Unset variable "cloud_network"
A used variable must be set or have a default value
Validation:
packer validate -syntax-only templates/builder.pkr.hcl
packer validate -syntax-only templates/docker.pkr.hcl
Both pass successfully
Impact:
- Allows validation without cloud_network set
- Maintains backward compatibility when cloud_network is provided
- No functional change to actual builds (cloud_network provided at runtime)
Related: opendaylight/releng-builder validation failure
Change-Id: I0da5fa2b8decb71444e4066d3a82f79435aa8130
Signed-off-by: Anil Belur <askb23@gmail.com>
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
}
variable "cloud_network" {
- type = string
+ type = string
+ default = null
}
variable "cloud_region" {
metadata = {
ci_managed = "yes"
}
- networks = ["${var.cloud_network}"]
+ networks = var.cloud_network != null ? ["${var.cloud_network}"] : null
region = "${var.cloud_region}"
source_image_name = "${var.base_image}"
metadata = {
ci_managed = "yes"
}
- networks = ["${var.cloud_network}"]
+ networks = var.cloud_network != null ? ["${var.cloud_network}"] : null
region = "${var.cloud_region}"
source_image_name = "${var.base_image}"