Skip to content

Latest commit

 

History

History
411 lines (284 loc) · 8.57 KB

vsphere-iso.mdx

File metadata and controls

411 lines (284 loc) · 8.57 KB
modeline description page_title sidebar_title
vim: set ft=pandoc:
This VMware Packer builder starts from an ISO and creates a vm using the vSphere API to build on a remote VMWare machine.
VSphere ISO - Builders
ISO

Packer Builder for VMware vSphere

Type: vsphere-iso Artifact BuilderId: jetbrains.vsphere

This builder uses the vSphere API, and creates virtual machines remotely. It starts from an ISO file and creates new VMs from scratch.

  • VMware Player is not required.
  • It uses the official vCenter API, and does not require ESXi host modification
  • This builder is supported for vSphere version 6.5 and greater. Builds on lower versions may work, but some configuration options may throw errors because they do not exist in the older versions of the vSphere API.

Examples

See complete Ubuntu, Windows, and macOS templates in the examples folder.

Configuration Reference

There are many configuration options available for this builder. In addition to the items listed here, you will want to look at the general configuration references for HTTP, Floppy, Boot, Hardware, Output, Run, Shutdown, Communicator, Export, configuration references, which are necessary for this build to succeed and can be found further down the page.

@include 'builder/vsphere/iso/Config-not-required.mdx'

Boot Configuration

@include 'packer-plugin-sdk/bootcommand/BootConfig.mdx'

We send each character to the VM with a default delay of 100ms between groups. The delay alleviates possible issues with latency and CPU contention. If you notice missing keys, you can tune this delay by specifying "boot_keygroup_interval" in your Packer template, for example:

{
  "builders": [
    {
      "type": "vsphere-iso",
      "boot_keygroup_interval": "500ms"
      ...
    }
  ]
}
source "vsphere-iso" "example" {
    boot_keygroup_interval = "500ms"
    # ...
}

Optional:

@include 'packer-plugin-sdk/bootcommand/BootConfig-not-required.mdx'

@include 'builder/vsphere/common/BootConfig-not-required.mdx'

Http directory configuration

@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig.mdx'

Optional:

@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig-not-required.mdx'

Floppy configuration

@include 'builder/vsphere/common/FloppyConfig-not-required.mdx'

Connection Configuration

@include 'builder/vsphere/common/ConnectConfig-not-required.mdx'

Hardware Configuration

@include 'builder/vsphere/common/HardwareConfig-not-required.mdx'

Location Configuration

@include 'builder/vsphere/common/LocationConfig-not-required.mdx'

Run Configuration

@include 'builder/vsphere/common/RunConfig-not-required.mdx'

Shutdown Configuration

@include 'builder/vsphere/common/ShutdownConfig-not-required.mdx'

Wait Configuration

@include 'builder/vsphere/common/WaitIpConfig-not-required.mdx'

ISO Configuration

@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig.mdx'

Required:

@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig-required.mdx'

Optional:

@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig-not-required.mdx'

CDRom Configuration

Each iso defined in the CDRom Configuration adds a new drive. If the "iso_url" is defined in addition to the "iso_paths", the "iso_url" is added to the VM first. This keeps the "iso_url" first in the boot order by default allowing the boot iso being defined by the iso_url and the vmware tools iso added from the datastore. Example:

"iso_urls": [
  "win10.iso",
  "http://example.org/isos/win10.iso"
],
"iso_paths": [
    "[] /usr/lib/vmware/isoimages/windows.iso"
],
iso_urls = [
  "win10.iso",
  "http://example.org/isos/win10.iso"
]

iso_paths = [
    "[] /usr/lib/vmware/isoimages/windows.iso"
]

@include 'builder/vsphere/common/CDRomConfig-not-required.mdx'

@include 'builder/vsphere/common/RemoveCDRomConfig-not-required.mdx'

@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig.mdx'

Optional:

@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig-not-required.mdx'

Create Configuration

@include 'builder/vsphere/iso/CreateConfig-not-required.mdx'

@include 'builder/vsphere/common/StorageConfig-not-required.mdx'

Network Adapter Configuration

@include 'builder/vsphere/iso/NIC.mdx'

@include 'builder/vsphere/iso/NIC-required.mdx'

Optional

@include 'builder/vsphere/iso/NIC-not-required.mdx'

Storage Configuration

@include 'builder/vsphere/common/DiskConfig.mdx'

@include 'builder/vsphere/common/DiskConfig-required.mdx'

Optional

@include 'builder/vsphere/common/DiskConfig-not-required.mdx'

Export Configuration

@include 'builder/vsphere/common/ExportConfig.mdx'

Optional:

@include 'builder/vsphere/common/ExportConfig-not-required.mdx'

Output Configuration:

@include 'builder/vsphere/common/OutputConfig-not-required.mdx'

Content Library Import Configuration

@include 'builder/vsphere/common/ContentLibraryDestinationConfig.mdx'

@include 'builder/vsphere/common/ContentLibraryDestinationConfig-not-required.mdx'

Minimal example of usage to import a VM template:

	"content_library_destination" : {
	    "library": "Packer Library Test"
	}
	content_library_destination {
			library = "Packer Library Test"
	}

Minimal example of usage to import a OVF template:

	"content_library_destination" : {
	    "library": "Packer Library Test",
	    "ovf": true
	}
	content_library_destination {
			library = "Packer Library Test"
			ovf = true
	}

Extra Configuration Parameters

@include 'builder/vsphere/common/ConfigParamsConfig-not-required.mdx'

Communicator configuration

Optional common fields:

@include 'packer-plugin-sdk/communicator/Config-not-required.mdx'

Optional SSH fields:

@include 'packer-plugin-sdk/communicator/SSH-not-required.mdx'

@include 'packer-plugin-sdk/communicator/SSH-Private-Key-File-not-required.mdx'

Optional WinRM fields:

@include 'packer-plugin-sdk/communicator/WinRM-not-required.mdx'

Working With Clusters And Hosts

Standalone Hosts

Only use the host option. Optionally specify a resource_pool:

"host": "esxi-1.vsphere65.test",
"resource_pool": "pool1",
host = ""esxi-1.vsphere65.test""
resource_pool = "pool1"

Clusters Without DRS

Use the cluster and hostparameters:

"cluster": "cluster1",
"host": "esxi-2.vsphere65.test",
cluster = "cluster1"
host = "esxi-2.vsphere65.test"

Clusters With DRS

Only use the cluster option. Optionally specify a resource_pool:

"cluster": "cluster2",
"resource_pool": "pool1",
cluster = "cluster2"
resource_pool = "pool1"

Required vSphere Permissions

  • VM folder (this object and children):
    Virtual machine -> Inventory
    Virtual machine -> Configuration
    Virtual machine -> Interaction
    Virtual machine -> Snapshot management
    Virtual machine -> Provisioning
    
    Individual privileges are listed in jetbrains-infra/packer-builder-vsphere#97 (comment).
  • Resource pool, host, or cluster (this object):
    Resource -> Assign virtual machine to resource pool
    
  • Host in clusters without DRS (this object):
    Read-only
    
  • Datastore (this object):
    Datastore -> Allocate space
    Datastore -> Browse datastore
    Datastore -> Low level file operations
    
  • Network (this object):
    Network -> Assign network
    
  • Distributed switch (this object):
    Read-only
    

For floppy image upload:

  • Datacenter (this object):
    Datastore -> Low level file operations
    
  • Host (this object):
    Host -> Configuration -> System Management