Looking for explanation on how to use `iso_paths` in combination with a Content Library

According to the documentation of builder vsphere-iso it’s possible to either specify iso files directly on a datastore, or in a Content Library (VSphere ISO - Builders | Packer by HashiCorp).

However when I specify an iso in that format (also tried it without the subfolder):

 "iso_paths": [
   "ISO-files/VMware-tools-windows-11.2.1-17243207/VMware-tools-windows-11.2.1-17243207.iso"
 ],

I get the error error mounting an image 'ISO-files/VMware-tools-windows-11.2.1-17243207/VMware-tools-windows-11.2.1-17243207.iso': Invalid datastore path 'ISO-files/VMware-tools-windows-11.2.1-17243207/VMware-tools-windows-11.2.1-17243207.iso'

I tried looking for clues on how to use it in the relevant PR (Accept content library path in iso_paths by sylviamoss · Pull Request #9801 · hashicorp/packer · GitHub) but it just confuses me further :frowning:

I’m using packer 1.6.6 btw

If that’s your Content Library path, like libraryName/itemName/fileName, then it is supposed to work. Could you share the logs of your build please when you run it with PACKER_LOG=1?

This image should hopefully confirm I’m using the correct path:

The logs of my build (relevant portion starts at line 145 I assume): + packer build -on-error=cleanup -var-file=packer/variables.vsphere.json - - Pastebin.com

For reference, I’m testing this on the following vCenter:

  • Version: 7.0.1
  • Build: 17005016

I’ve tested your path against the path validation code and it checks successfully. From the error below I know that Packer is unable to find the Content Library.

packer-builder-vsphere-iso plugin: ISO path not identified as a Content Library path

Could you make sure that the Content Library is accessible via the host/cluster/user you’re using?

Thanks for taking the time to look into this.

The line you quoted is line 142, which refers to the ISO provided through iso_url; then on line 145-146 the ISO provided through iso_paths is tried, this is where I’m actually asking this question for.

The account used should have global admin rights on the entire vCenter cluster and all resources (it’s the default administrator@vsphere.local).

Is there any trace log-level I can enable to try and figure this out?

Sorry, got confused between the lines. It actually can find the Content Library but can’t find the datastore ID for it.
What Packer does is call the vcenter API asking for the datastore name for a given Content Library ID and that call is returning an error.

Everything that Packer does is possible to do via govc. I suggest you try to do this workflow with govc and see if it returns the datastore id.
Here their usage docs: govmomi/USAGE.md at master · vmware/govmomi · GitHub

I would use the following to get the datastore id:

govc library.info [options]

Then, to get the datastore info:

govc datastore.info [options]

Remember to be logged in with the same account that you’re with Packer.

This is the output:

PS C:> .\govc_windows_amd64.exe datastore.info -dc=Datacenter
Name: Datastore03.SSD
Path: /Datacenter/datastore/Datastore03.SSD
Type: VMFS
URL: ds:///vmfs/volumes/5ea41ab8-57202e78-3b6d-0cc47ac59bca/
Capacity: 238.2 GB
Free: 224.3 GB
Name: Datastore02.SSD
Path: /Datacenter/datastore/Datastore02.SSD
Type: VMFS
URL: ds:///vmfs/volumes/5dc9930e-debc25df-a757-0cc47ac59bca/
Capacity: 1907.5 GB
Free: 837.2 GB
Name: Datastore01.NAS
Path: /Datacenter/datastore/Datastore01.NAS
Type: VMFS
URL: ds:///vmfs/volumes/5b903f74-97c7c00b-699a-0cc47ac59bca/
Capacity: 3071.8 GB
Free: 948.9 GB
Name: Datastore01.SSD
Path: /Datacenter/datastore/Datastore01.SSD
Type: VMFS
URL: ds:///vmfs/volumes/5ab39f90-a169ceba-2f79-0cc47ac59bca/
Capacity: 469.5 GB
Free: 291.8 GB

PS C:> .\govc_windows_amd64.exe library.info
Name: ISO-files
ID: 5c2187fa-55c5-4285-b06b-3f5f1ff9428d
Path: /ISO-files
Description:
Version: 2
Created: Sat Jan 2 12:34:14 2021
StorageBackings:
DatastoreID: datastore-12
Type: DATASTORE

We need to figure out if datastore-12 is the ID of one of the datastores you can fetch from the first command.

Does it work if you do it like:

 .\govc_windows_amd64.exe datastore.info datastore-12

?

I just tried; it doesn’t seem to recognise datastore-12:

.\govc_windows_amd64.exe datastore.info -dc=Datacenter datastore-12
.\govc_windows_amd64.exe : datastore ‘datastore-12’ not found

Interestingly, a newly created Content Library shows actual datastore names as expected:

Name: ISO-files
ID: 5c2187fa-55c5-4285-b06b-3f5f1ff9428d
Path: /ISO-files
Description:
Version: 2
Created: Sat Jan 2 12:34:14 2021
StorageBackings:
DatastoreID: datastore-12
Type: DATASTORE
Name: OVA appliances
ID: 0512fac1-180a-485f-8428-44352ccf04f4
Path: /OVA appliances
Description:
Version: 2
Created: Tue Jan 12 10:33:30 2021
StorageBackings:
DatastoreID: Datastore01.NAS
Type: DATASTORE

I think I’ll try recreating the Content Library to see if it starts working then…

This is probably the same result Packer has when trying to get information from this datastore. Let me know if worked for the recreated Content Library.

Yeah, everything started working with the newly created CL. If I ever encounter it again, at least I know what’s happening :slight_smile: