Skip to content

Confusing behavior in declaring variables that are set via variable files  #11659

@ChrisDek

Description

@ChrisDek

Overview of the Issue

After switching to pkr.hcl I cannot use a vars file of any kind with my template.
Previously I used .json and had separated templates and config I do not want in our repo for security reasons.
To be able to use vshpere iso builders new feature of adding a vTPM during build I could only get the newest version of the builder when adding the version in hcl. So I converted a .json to .pkr.hcl. But I cannot find a way to add a variables.pkr.hcl to the template. -var-file does not like the .pkr.hcl. Adding the variables.json also does not work. Also tried variables.auto.pkr.hcl and variables.pkvars.hcl There were older bug that were closed without it being obvious that this is fixed.

Reproduction Steps

Create a .pkr.hcl template. Also add a variables.pkr.hcl

PACKER_LOG=1 packer build .
with template and variables.pkr.hcl in the current folder

Packer version

1.7.10

Simplified Packer Template

declarative
vcenter_network = "qa.lan"
also tried with variable datatype
variable "vcenter_network" {
type = string
default = "qa.lan"
}

Operating system and Environment details

ubuntu 20.04.4 LTS on amd64
running vsphere iso 1.8.3 against a 7.0.2 vCenter

Log Fragments and crash.log files

Error: Unsupported argument

on variables.auto.pkr.hcl line 8:
8: vcenter_network = "qa.lan"

An argument named "vcenter_network" is not expected here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdocshcl2sync to jiraFor issues that need to be imported to Packer internal JIRA backlog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions