vSphere-iso -> Notes option

Hello,
Concerning the Hashicorp Packer builder “vsphere-iso”. The option for “notes”, under the Create Configuration section is set to string.

Is there a way to pass multiple lines with a ‘new line’ character within the string? I have tried a bunch of hacks but cannot seem to get anything put a continuous line.

What it should look like in vCenter:

OS=Ubuntu20.04LTS
IP=10.10.10.10
Services=K8_host
Business Owner=Engineer#1
Business Dept=Marketing

How I do this in vRO (JS):

var myAnnotation = (
	"OS= " + operatingSystem + "\r\n" +
	"IP= " + vmIpAddress + "\r\n" +
	"Services= " + vmServices + "\r\n" +
	"Business Owner= " + businessOwner + "\r\n" +
	"Business Dept= " + businessDept
	);

So just figured it out.

  • If you are in vCenter 7+ and using the new view, the notes section might still look like one continuous line but it is not. You can switch to “classic view” within vCenter and validate the notes section.
notes  = "OS=CentOS7_x64\r\nIP=10.10.10.10\r\nServices=K8_host\r\nBussinesOwner=Engineer#1\r\nBussinessDept=Marketing"

of course you can use variables within the string to make life easier.

Thanks tlb1galaxy, you pointed me in the right direction.

For anyone else trying to set notes to a multiline string, the following works and I find it easier to read than a really long string with linefeeds within it.

locals {
    ...
    iso_file = "[DS1] ISOs/example.iso"

    blah = [
      "Template created by Packer based on XXXX",
      join(" : ", ["Build date : ", timestamp() ] ),
      join(" : ", ["ISO file : ", local.iso_file ] ),
    ]
    notes = join("\r\n", local.blah)
}

I concur that you need to switch to “Classic view” (or edit the notes) in order to view the notes as a multiline string. The “new view” ignores linefeeds :frowning: