412 lines
8.6 KiB
Plaintext
Raw Permalink Normal View History

---
modeline: |
vim: set ft=pandoc:
description: |
2020-03-18 18:46:47 -04:00
This VMware Packer builder starts from an ISO and creates a vm using the
vSphere API to build on a remote VMWare machine.
page_title: VSphere ISO - Builders
sidebar_title: VSphere 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.
2020-03-31 17:40:07 -04:00
- It uses the official vCenter API, and does not require ESXi host [modification](/docs/builders/vmware-iso#building-on-a-remote-vsphere-hypervisor)
- This builder is supported for vSphere version 6.5 and greater. Builds on lower
2020-12-04 16:00:53 -05:00
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](https://github.com/hashicorp/packer/tree/master/builder/vsphere/examples/).
# 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](#http-directory-configuration),
[Floppy](#floppy-configuration),
[Boot](#boot-configuration),
[Hardware](#hardware-configuration),
[Output](#output-configuration),
[Run](#run-configuration),
[Shutdown](#shutdown-configuration),
[Communicator](#communicator-configuration),
[Export](#export-configuration),
configuration references, which are
necessary for this build to succeed and can be found further down the page.
2020-03-23 20:02:12 -04:00
@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:
<Tabs>
<Tab heading="JSON">
```json
{
"builders": [
{
"type": "vsphere-iso",
"boot_keygroup_interval": "500ms"
...
}
]
}
```
</Tab>
<Tab heading="HCL2">
```hcl
source "vsphere-iso" "example" {
boot_keygroup_interval = "500ms"
# ...
}
```
</Tab>
</Tabs>
#### Optional:
@include 'packer-plugin-sdk/bootcommand/BootConfig-not-required.mdx'
@include 'builder/vsphere/common/BootConfig-not-required.mdx'
### Http directory configuration
2020-11-17 17:18:45 -08:00
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig.mdx'
#### Optional:
2020-11-17 17:18:45 -08:00
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig-not-required.mdx'
### Floppy configuration
2020-09-18 17:09:01 +02:00
@include 'builder/vsphere/common/FloppyConfig-not-required.mdx'
### Connection Configuration
2020-03-18 18:46:47 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/vsphere/common/ConnectConfig-not-required.mdx'
### Hardware Configuration
2020-03-18 18:46:47 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/vsphere/common/HardwareConfig-not-required.mdx'
### Location Configuration
2020-03-18 18:46:47 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/vsphere/common/LocationConfig-not-required.mdx'
### Run Configuration
2020-03-18 18:46:47 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/vsphere/common/RunConfig-not-required.mdx'
### Shutdown Configuration
2020-03-18 18:46:47 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/vsphere/common/ShutdownConfig-not-required.mdx'
### Wait Configuration
2020-03-18 18:46:47 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/vsphere/common/WaitIpConfig-not-required.mdx'
### ISO Configuration
2020-11-17 17:18:45 -08:00
@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig.mdx'
#### Required:
2020-11-17 17:18:45 -08:00
@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig-required.mdx'
#### Optional:
2020-11-17 17:18:45 -08:00
@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:
<Tabs>
<Tab heading="JSON">
```json
"iso_urls": [
"win10.iso",
"http://example.org/isos/win10.iso"
],
"iso_paths": [
"[] /usr/lib/vmware/isoimages/windows.iso"
],
```
</Tab>
<Tab heading="HCL2">
```hcl
iso_urls = [
"win10.iso",
"http://example.org/isos/win10.iso"
]
iso_paths = [
"[] /usr/lib/vmware/isoimages/windows.iso"
]
```
</Tab>
</Tabs>
@include 'builder/vsphere/common/CDRomConfig-not-required.mdx'
@include 'builder/vsphere/common/RemoveCDRomConfig-not-required.mdx'
2020-11-17 17:18:45 -08:00
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig.mdx'
2020-09-18 17:09:01 +02:00
#### Optional:
2020-11-17 17:07:02 -08:00
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig-not-required.mdx'
2020-09-18 17:09:01 +02:00
### Create Configuration
2020-03-18 18:46:47 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/vsphere/iso/CreateConfig-not-required.mdx'
@include 'builder/vsphere/common/StorageConfig-not-required.mdx'
### Network Adapter Configuration
2020-03-18 18:46:47 -04:00
@include 'builder/vsphere/iso/NIC.mdx'
2020-03-23 20:02:12 -04:00
@include 'builder/vsphere/iso/NIC-required.mdx'
#### Optional
@include 'builder/vsphere/iso/NIC-not-required.mdx'
### Storage Configuration
2020-03-18 18:46:47 -04:00
@include 'builder/vsphere/common/DiskConfig.mdx'
@include 'builder/vsphere/common/DiskConfig-required.mdx'
2020-03-24 19:48:37 -04:00
#### Optional
@include 'builder/vsphere/common/DiskConfig-not-required.mdx'
### Export Configuration
2020-04-02 14:15:08 -04:00
@include 'builder/vsphere/common/ExportConfig.mdx'
#### Optional:
2020-04-02 14:15:08 -04:00
@include 'builder/vsphere/common/ExportConfig-not-required.mdx'
#### Output Configuration:
2020-04-02 14:15:08 -04:00
@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:
<Tabs>
<Tab heading="JSON">
```json
"content_library_destination" : {
"library": "Packer Library Test"
}
```
</Tab>
<Tab heading="HCL2">
```hcl
content_library_destination {
library = "Packer Library Test"
}
```
</Tab>
</Tabs>
Minimal example of usage to import a OVF template:
<Tabs>
<Tab heading="JSON">
```json
"content_library_destination" : {
"library": "Packer Library Test",
"ovf": true
}
```
</Tab>
<Tab heading="HCL2">
```hcl
content_library_destination {
library = "Packer Library Test"
ovf = true
}
```
</Tab>
</Tabs>
### Extra Configuration Parameters
2020-03-18 18:46:47 -04:00
2020-03-23 20:02:12 -04:00
@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'
2020-10-09 13:09:06 -07:00
## Working With Clusters And Hosts
2020-03-18 18:46:47 -04:00
#### Standalone Hosts
2020-03-18 18:46:47 -04:00
Only use the `host` option. Optionally specify a `resource_pool`:
2020-03-18 18:46:47 -04:00
<Tabs>
<Tab heading="JSON">
2020-03-31 18:47:06 -04:00
```json
"host": "esxi-1.vsphere65.test",
"resource_pool": "pool1",
```
</Tab>
<Tab heading="HCL2">
```hcl
host = ""esxi-1.vsphere65.test""
resource_pool = "pool1"
```
</Tab>
</Tabs>
#### Clusters Without DRS
2020-03-18 18:46:47 -04:00
Use the `cluster` and `host`parameters:
<Tabs>
<Tab heading="JSON">
2020-03-31 18:47:06 -04:00
```json
"cluster": "cluster1",
"host": "esxi-2.vsphere65.test",
```
</Tab>
<Tab heading="HCL2">
```hcl
cluster = "cluster1"
host = "esxi-2.vsphere65.test"
```
</Tab>
</Tabs>
#### Clusters With DRS
2020-03-18 18:46:47 -04:00
Only use the `cluster` option. Optionally specify a `resource_pool`:
2020-03-18 18:46:47 -04:00
<Tabs>
<Tab heading="JSON">
2020-03-31 18:47:06 -04:00
```json
"cluster": "cluster2",
"resource_pool": "pool1",
```
</Tab>
<Tab heading="HCL2">
```hcl
cluster = "cluster2"
resource_pool = "pool1"
```
</Tab>
</Tabs>
## Required vSphere Permissions
2020-03-18 18:46:47 -04:00
- VM folder (this object and children):
2020-03-27 14:22:33 -04:00
```text
2020-03-18 18:46:47 -04:00
Virtual machine -> Inventory
Virtual machine -> Configuration
Virtual machine -> Interaction
Virtual machine -> Snapshot management
Virtual machine -> Provisioning
```
Individual privileges are listed in https://github.com/jetbrains-infra/packer-builder-vsphere/issues/97#issuecomment-436063235.
- Resource pool, host, or cluster (this object):
2020-03-27 14:22:33 -04:00
```text
2020-03-18 18:46:47 -04:00
Resource -> Assign virtual machine to resource pool
```
- Host in clusters without DRS (this object):
2020-03-27 14:22:33 -04:00
```text
2020-03-18 18:46:47 -04:00
Read-only
```
- Datastore (this object):
2020-03-27 14:22:33 -04:00
```text
2020-03-18 18:46:47 -04:00
Datastore -> Allocate space
Datastore -> Browse datastore
Datastore -> Low level file operations
```
- Network (this object):
2020-03-27 14:22:33 -04:00
```text
2020-03-18 18:46:47 -04:00
Network -> Assign network
```
- Distributed switch (this object):
2020-03-27 14:22:33 -04:00
```text
2020-03-18 18:46:47 -04:00
Read-only
```
For floppy image upload:
2020-03-18 18:46:47 -04:00
- Datacenter (this object):
2020-03-27 14:22:33 -04:00
```text
2020-03-18 18:46:47 -04:00
Datastore -> Low level file operations
```
- Host (this object):
2020-03-27 14:22:33 -04:00
```text
2020-03-18 18:46:47 -04:00
Host -> Configuration -> System Management
```