hashicorp / packer-plugin-vsphere

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

`vsphere-iso`: "error extracting VM metadata: NoPermission" #287

Closed dkirrane closed 1 year ago

dkirrane commented 1 year ago

Overview of the Issue

Packer build completes successfully but fails to create the VM template. It throws below error extracting VM metadata: NoPermission when converting the VM to a VM template

==> ubuntu_base.vsphere-iso.ubuntu_base: Executing shutdown command...
2023/07/06 13:04:12 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/07/06 13:04:12 Shutdown command: echo '<sensitive>123' | sudo -S -E shutdown -P now
2023/07/06 13:04:12 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/07/06 13:04:12 [DEBUG] Opening new ssh session
2023/07/06 13:04:12 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/07/06 13:04:12 [DEBUG] starting remote command: echo '<sensitive>' | sudo -S -E shutdown -P now
2023/07/06 13:04:12 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/07/06 13:04:12 Waiting max 15m0s for shutdown to complete
2023/07/06 13:04:12 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/07/06 13:04:12 [ERROR] Remote command exited without exit status or exit signal.
==> ubuntu_base.vsphere-iso.ubuntu_base: Deleting Floppy drives...
==> ubuntu_base.vsphere-iso.ubuntu_base: Eject CD-ROM drives...
==> ubuntu_base.vsphere-iso.ubuntu_base: Deleting CD-ROM drives...
==> ubuntu_base.vsphere-iso.ubuntu_base: Convert VM into template...
2023/07/06 13:04:29 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/07/06 13:04:29 [TRACE] error extracting VM metadata: NoPermission
2023/07/06 13:04:29 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/07/06 13:04:29 Deleting CD disk: /tmp/packer3387111696.iso
2023/07/06 13:04:29 [INFO] (telemetry) ending vsphere-iso.ubuntu_base
Build 'ubuntu_base.vsphere-iso.ubuntu_base' finished after 35 minutes 6 seconds.

==> Wait completed after 35 minutes 6 seconds

==> Builds finished. The artifacts of successful builds are:
--> ubuntu_base.vsphere-iso.ubuntu_base: ubuntu-base-22.04.2-LTS

Packer Version

Please provide the Packer version.

packer --version
2023/07/06 12:29:16 [INFO] Packer version: 1.8.6 [go1.18.9 linux amd64]
2023/07/06 12:29:16 [TRACE] discovering plugins in /usr/local/bin
2023/07/06 12:29:16 [TRACE] discovering plugins in /root/.config/packer/plugins
2023/07/06 12:29:16 [DEBUG] Discovered plugin: git = /root/.config/packer/plugins/github.com/ethanmdavidson/git/packer-plugin-git_v0.3.4_x5.0_linux_amd64
2023/07/06 12:29:16 [DEBUG] Discovered plugin: vsphere = /root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64
2023/07/06 12:29:16 found external [commit repository tree] datasource from git plugin
2023/07/06 12:29:16 [INFO] found external [clone iso supervisor] builders from vsphere plugin
2023/07/06 12:29:16 [INFO] found external [-packer-default-plugin-name- template] post-processors from vsphere plugin
2023/07/06 12:29:16 [TRACE] discovering plugins in .
2023/07/06 12:29:16 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/07/06 12:29:16 [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/07/06 12:29:16 [WARN] Config file doesn't exist: /root/.packerconfig
2023/07/06 12:29:16 [INFO] Setting cache directory: /root/.cache/packer
e: Running in background, not using a TTY
2023/07/06 12:29:16 [INFO] (telemetry) Finalizing.
1.8.6
2023/07/06 12:29:17 waiting for all plugin processes to complete...

Please select the builder.

VMware vSphere Version

Please provide the VMware vSphere version.

Guest Operating System

ubuntu 22.04.2-LTS x64

vSphere User Permissions

The vSphere user I'm using has the following permissions

    ContentLibrary.AddLibraryItem
    ContentLibrary.CheckInTemplate
    ContentLibrary.CheckOutTemplate
    ContentLibrary.GetConfiguration
    ContentLibrary.ReadStorage
    ContentLibrary.UpdateLibraryItem
    ContentLibrary.UpdateSession
    Datastore.AllocateSpace
    Datastore.Browse
    Datastore.DeleteFile
    Datastore.FileManagement
    Datastore.UpdateVirtualMachineFiles
    Datastore.UpdateVirtualMachineMetadata
    Folder.Create
    Folder.Delete
    Folder.Move
    Folder.Rename
    Host.Config.SystemManagement
    Network.Assign
    Resource.AssignVMToPool
    System.Anonymous
    System.Read
    System.View
    VApp.Export
    VirtualMachine.Config.AddExistingDisk
    VirtualMachine.Config.AddNewDisk
    VirtualMachine.Config.AddRemoveDevice
    VirtualMachine.Config.AdvancedConfig
    VirtualMachine.Config.Annotation
    VirtualMachine.Config.CPUCount
    VirtualMachine.Config.ChangeTracking
    VirtualMachine.Config.DiskExtend
    VirtualMachine.Config.DiskLease
    VirtualMachine.Config.EditDevice
    VirtualMachine.Config.HostUSBDevice
    VirtualMachine.Config.ManagedBy
    VirtualMachine.Config.Memory
    VirtualMachine.Config.MksControl
    VirtualMachine.Config.QueryFTCompatibility
    VirtualMachine.Config.QueryUnownedFiles
    VirtualMachine.Config.RawDevice
    VirtualMachine.Config.ReloadFromPath
    VirtualMachine.Config.RemoveDisk
    VirtualMachine.Config.Rename
    VirtualMachine.Config.ResetGuestInfo
    VirtualMachine.Config.Resource
    VirtualMachine.Config.Settings
    VirtualMachine.Config.SwapPlacement
    VirtualMachine.Config.ToggleForkParent
    VirtualMachine.Config.UpgradeVirtualHardware
    VirtualMachine.Interact.AnswerQuestion
    VirtualMachine.Interact.Backup
    VirtualMachine.Interact.ConsoleInteract
    VirtualMachine.Interact.CreateScreenshot
    VirtualMachine.Interact.CreateSecondary
    VirtualMachine.Interact.DefragmentAllDisks
    VirtualMachine.Interact.DeviceConnection
    VirtualMachine.Interact.DisableSecondary
    VirtualMachine.Interact.DnD
    VirtualMachine.Interact.EnableSecondary
    VirtualMachine.Interact.GuestControl
    VirtualMachine.Interact.MakePrimary
    VirtualMachine.Interact.Pause
    VirtualMachine.Interact.PowerOff
    VirtualMachine.Interact.PowerOn
    VirtualMachine.Interact.PutUsbScanCodes
    VirtualMachine.Interact.Record
    VirtualMachine.Interact.Replay
    VirtualMachine.Interact.Reset
    VirtualMachine.Interact.SESparseMaintenance
    VirtualMachine.Interact.SetCDMedia
    VirtualMachine.Interact.SetFloppyMedia
    VirtualMachine.Interact.Suspend
    VirtualMachine.Interact.SuspendToMemory
    VirtualMachine.Interact.TerminateFaultTolerantVM
    VirtualMachine.Interact.ToolsInstall
    VirtualMachine.Interact.TurnOffFaultTolerance
    VirtualMachine.Inventory.Create
    VirtualMachine.Inventory.CreateFromExisting
    VirtualMachine.Inventory.Delete
    VirtualMachine.Inventory.Move
    VirtualMachine.Inventory.Register
    VirtualMachine.Inventory.Unregister
    VirtualMachine.Provisioning.Clone
    VirtualMachine.Provisioning.CloneTemplate
    VirtualMachine.Provisioning.CreateTemplateFromVM
    VirtualMachine.Provisioning.Customize
    VirtualMachine.Provisioning.DeployTemplate
    VirtualMachine.Provisioning.DiskRandomAccess
    VirtualMachine.Provisioning.DiskRandomRead
    VirtualMachine.Provisioning.FileRandomAccess
    VirtualMachine.Provisioning.GetVmFiles
    VirtualMachine.Provisioning.MarkAsTemplate
    VirtualMachine.Provisioning.MarkAsVM
    VirtualMachine.Provisioning.ModifyCustSpecs
    VirtualMachine.Provisioning.PromoteDisks
    VirtualMachine.Provisioning.PutVmFiles
    VirtualMachine.Provisioning.ReadCustSpecs
    VirtualMachine.State.CreateSnapshot
    VirtualMachine.State.RemoveSnapshot
    VirtualMachine.State.RenameSnapshot
    VirtualMachine.State.RevertToSnapshot
tenthirtyam commented 1 year ago

Was this issue ever resolved?

dkirrane commented 1 year ago

nope. No idea what permission I was missing if any.

dkirrane commented 1 year ago

@tenthirtyam - any ideas which vSphere role might be missing here?

tenthirtyam commented 1 year ago

Compare against this list: https://vmware-samples.github.io/packer-examples-for-vsphere/getting-started/privileges/