hashicorp / packer-plugin-vsphere

Packer plugin for VMware vSphere Builder
https://www.packer.io/docs/builders/vsphere
Mozilla Public License 2.0
94 stars 91 forks source link

Variables in post-processor like vsphere-template #330

Closed nikstuckenbrock closed 9 months ago

nikstuckenbrock commented 9 months ago

When filing a bug please include the following headings, if possible.

build {
  post-processor "vsphere-template" {
    host = var.vcenter_esxi_host
    username = "myusername"
    password = "magicfoo"
    datacenter = "magicfoo"
    folder = "/my_folder"
    reregister_vm = true
  }
}

Overview of the Issue

I've also have a corresponding file variables.pkr.hcl. But for some reason I get an errro host must be set. For some other plugins I've seen that there is no implementation for the variables in post processors. I've also tried using locals, same result.

Reproduction Steps

Just use variables declared in a variable file in the post-processor.

Packer Version

1.9.4

Plugin Version and Builders

Please provide the plugin version.

      version = ">= 0.0.1"
      source = "github.com/hashicorp/vsphere"
    }

Please select the builder.

lbajolet-hashicorp commented 9 months ago

Hi @nikstuckenbrock,

I'd be surprised if that was a bug with the plugin, since variable references like this are coming from Packer. Does this break too with a literal string?

On another note, may I have more information on how you invoke Packer? I suspect the variable file may not be loaded. Also, does your variable have a default value? If the variable file is not loaded properly, this may be why the variable is empty, leading to the problem you're experiencing here.

nikstuckenbrock commented 9 months ago

Hey @lbajolet-hashicorp,

thanks for the quick reply. I've somehow messed up my variables and found the mistake I've made. Sorry for taking up your time. It seems like everything is working now.