Go to file
Michael Kuzmin e4f6d5d691 fix VPN connection 2018-10-17 17:48:23 +03:00
clone Fix build cancellation (#101) 2018-05-16 16:05:08 +03:00
cmd Build two independent plugins 2018-01-24 21:01:04 +03:00
common Fix tests 2018-05-16 16:53:32 +03:00
driver firmware: validation & tests 2018-10-17 02:45:22 +03:00
examples Update Docs for v2.0 (#96) 2018-05-23 02:50:53 +03:00
iso firmware: validation & tests 2018-10-17 02:45:22 +03:00
test fix VPN connection 2018-10-17 17:48:23 +03:00
.gitignore Update hashicorp/yamux dependency 2018-10-17 17:25:33 +03:00
Gopkg.lock Update hashicorp/yamux dependency 2018-10-17 17:25:33 +03:00
Gopkg.toml Fix #107 RPC client in the plugin uses incompatible version of a message codec, so Packer core cannot read them 2018-05-22 21:58:23 +03:00
LICENSE.txt Add Mozilla Public License 2.0 - the same as in Packer itself 2017-08-24 14:03:49 +03:00
README.md add build instructions (#165) 2018-10-17 03:15:01 +03:00
build.sh Switch from Glide to dep 2018-03-24 02:32:10 +03:00
docker-compose.yml build by Go 1.10.4 2018-10-17 13:08:32 +03:00
teamcity-services.yml Fix VPN 2018-04-25 08:58:24 +03:00
test.sh Revert "Catch test compilation errors" 2018-05-16 16:42:49 +03:00

README.md

Team project Github All Releases TeamCity build status

Packer Builder for VMware vSphere

This a plugin for HashiCorp Packer. It uses native vSphere API, and creates virtual machines remotely.

vsphere-iso builder creates new VMs from scratch. vsphere-clone builder clones VMs from existing templates.

  • VMware Player is not required.
  • Official vCenter API is used, no ESXi host modification is required.

Installation

  • Download binaries from the releases page.
  • Install the plugins, or simply put them into the same directory with JSON templates. On Linux and macOS run chmod +x on the files.

Build

Install Go and dep, run build.sh.

Or build inside a container by Docker Compose:

docker-compose run build

The binaries will be in bin/ directory.

Artifacts can be also downloaded from TeamCity builds.

Examples

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

Parameter Reference

Connection

  • vcenter_server(string) - vCenter server hostname.
  • username(string) - vSphere username.
  • password(string) - vSphere password.
  • insecure_connection(boolean) - Do not validate vCenter server's TLS certificate. Defaults to false.
  • datacenter(string) - VMware datacenter name. Required if there is more than one datacenter in vCenter.

VM Location

  • vm_name(string) - Name of the new VM to create.
  • folder(string) - VM folder to create the VM in.
  • host(string) - ESXi host where target VM is created. A full path must be specified if the host is in a folder. For example folder/host. See the Specifying Clusters and Hosts section above for more details.
  • cluster(string) - ESXi cluster where target VM is created. See Working with Clusters section.
  • resource_pool(string) - VMWare resource pool. Defaults to the root resource pool of the host or cluster.
  • datastore(string) - VMWare datastore. Required if host is a cluster, or if host has multiple datastores.

VM Location (vsphere-clone only)

  • template(string) - Name of source VM. Path is optional.
  • linked_clone(boolean) - Create VM as a linked clone from latest snapshot. Defaults to false.

Hardware

  • CPUs(number) - Number of CPU sockets.
  • CPU_limit(number) - Upper limit of available CPU resources in MHz.
  • CPU_reservation(number) - Amount of reserved CPU resources in MHz.
  • CPU_hot_plug(boolean) - Enable CPU hot plug setting for virtual machine. Defaults to false.
  • RAM(number) - Amount of RAM in MB.
  • RAM_reservation(number) - Amount of reserved RAM in MB.
  • RAM_reserve_all(boolean) - Reserve all available RAM. Defaults to false. Cannot be used together with RAM_reservation.
  • RAM_hot_plug(boolean) - Enable RAM hot plug setting for virtual machine. Defaults to false.
  • disk_size(number) - The size of the disk in MB.
  • NestedHV(boolean) - Enable nested hardware virtualization for VM. Defaults to false.
  • configuration_parameters(map) - Custom parameters.
  • boot_order(string) - Priority of boot devices. Defaults to disk,cdrom

Hardware (vsphere-iso only)

  • vm_version(number) - Set VM hardware version. Defaults to the most current VM hardware version supported by vCenter. See VMWare article 1003746 for the full list of supported VM hardware versions.
  • guest_os_type(string) - Set VM OS type. Defaults to otherGuest. See here for a full list of possible values.
  • disk_controller_type(string) - Set VM disk controller type. Example pvscsi.
  • disk_thin_provisioned(boolean) - Enable VMDK thin provisioning for VM. Defaults to false.
  • network(string) - Set network VM will be connected to.
  • network_card(string) - Set VM network card type. Example vmxnet3.
  • usb_controller(boolean) - Create USB controller for virtual machine. Defaults to false.
  • firmware(string) - Set the Firmware at machine creation. Example efi. Defaults to bios

Boot (vsphere-iso only)

  • boot_wait(string) Amount of time to wait for the VM to boot. Examples 45s and 10m. Defaults to 10 seconds. See the Go Lang ParseDuration documentation for full details.
  • boot_command(array of strings) - List of commands to type when the VM is first booted. Used to initalize the operating system installer.
  • floppy_dirs(array of strings) - Seems to not do anything useful yet. Not implemented.
  • floppy_files(array of strings) - List of local files to be mounted to the VM floppy drive. Can be used to make Debian preseed or RHEL kickstart files available to the VM.
  • floppy_img_path(string) - Data store path to a floppy image that will be mounted to the VM. Cannot be used with floppy_files or floppy_dir options. Example [datastore1] ISO/VMware Tools/10.2.0/pvscsi-Windows8.flp.
  • iso_paths(array of strings) - List of data store paths to ISO files that will be mounted to the VM. Example "[datastore1] ISO/ubuntu-16.04.3-server-amd64.iso".

Provision

  • communicator - ssh (default), winrm, or none.

  • ssh_username(string) - Username in guest OS.

  • ssh_password(string) - Password to access guest OS. Only specify ssh_password or ssh_private_key_file, but not both.

  • ssh_private_key_file(string) - Path to the SSH private key file to access guest OS. Only specify ssh_password or ssh_private_key_file, but not both.

  • winrm_username(string) - Username in guest OS.

  • winrm_password(string) - Password to access guest OS.

  • shutdown_command(string) - Specify a VM guest shutdown command. VMware guest tools are used by default.

  • shutdown_timeout(string) - Amount of time to wait for graceful VM shutdown. Examples 45s and 10m. Defaults to 5m(5 minutes). See the Go Lang ParseDuration documentation for full details.

Postprocessing

  • create_snapshot(boolean) - Create a snapshot when set to true, so the VM can be used as a base for linked clones. Defaults to false.
  • convert_to_template(boolean) - Convert VM to a template. Defaults to false.

Working with Clusters

Standalone Hosts

Only use the host option. Optionally specify a resource_pool:

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

Clusters Without DRS

Use the cluster and host parameters:

"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",