Go to file
Michael Kuzmin a12ff09f0a move setup back into builder 2017-07-01 15:52:49 +03:00
docker Rename artifacts 2017-06-27 10:55:49 +03:00
.gitignore fix Dockerfile 2017-05-16 08:49:32 +03:00
README.md Update README.md 2017-06-28 12:19:46 +03:00
artifact.go Rename artifacts 2017-06-27 10:55:49 +03:00
build.sh Installation scripts 2017-05-15 00:25:50 +03:00
builder.go move setup back into builder 2017-07-01 15:52:49 +03:00
config.go Add a snapshot (#22) 2017-06-27 10:32:59 +03:00
docker-compose.yml Rename artifacts 2017-06-27 10:55:49 +03:00
glide.lock Lock dependencies 2017-06-27 10:44:38 +03:00
glide.yaml Lock dependencies 2017-06-27 10:44:38 +03:00
main.go Builder (#2) 2017-05-09 17:23:57 +03:00
step_clone_vm.go move setup back into builder 2017-07-01 15:52:49 +03:00
step_configure_hw.go Added template conversion (#18) 2017-06-13 14:11:41 +03:00
step_create_snapshot.go Add a snapshot (#22) 2017-06-27 10:32:59 +03:00
step_run.go Builder (#2) 2017-05-09 17:23:57 +03:00
step_shutdown.go Added template conversion (#18) 2017-06-13 14:11:41 +03:00
step_template.go Add a snapshot (#22) 2017-06-27 10:32:59 +03:00

README.md

Packer Builder for VMware vSphere

This builder uses native vSphere API, and creates virtual machines remotely.

  • VMware Player is not required
  • Builds are incremental, VMs are not created from scratch but cloned from base templates - similar to amazon-ebs builder
  • Official vCenter API is used, no ESXi host modification is required

Usage

  • Download the plugin from Releases page
  • Install the plugin, or simply put it into the same directory with configuration files

Minimal Example

{
  "builders": [
    {
      "type": "vsphere",

      "url":      "https://vcenter.domain.com/sdk",
      "username": "root",
      "password": "secret",

      "template": "ubuntu",
      "vm_name":  "vm-1",
      "host":     "esxi-1.domain.com",

      "ssh_username": "root",
      "ssh_password": "secret"
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline": [ "echo hello" ]
    }
  ]
}

Parameters

Required

  • url - URL of vCenter API enpoint.
  • username - vSphere username.
  • password - vSphere password.
  • template - name of source VM.
  • vm_name - name of target VM.
  • host - vSphere host where target VM is created.
  • ssh_username - username in guest OS.
  • ssh_password - password in guest OS.

Optional

Destination:

  • dc_name - required if there are several datacenters.
  • folder_name - VM folder where target VM is created.
  • resource_pool - by default a root of vSphere host.
  • datastore - required if vSphere host has multiple datastores attached.
  • linked_clone - create VM as a linked clone from latest snapshot. false by default.

Hardware customization:

  • cpus - number of CPU sockets. Inherited from source VM by default.
  • ram - Amount of RAM in megabytes. Inherited from source VM by default.

Post-processing:

  • shutdown_command - VMware guest tools are used by default.
  • create_snapshot - add a snapshot, so VM can be used as a base for linked clones. false by default.
  • convert_to_template - convert VM to a template. false by default.

Complete Example

{
  "variables": {
    "vsphere_password": "secret",
    "guest_password": "secret"
  },

  "builders": [
    {
      "type": "vsphere",

      "url": "https://vcenter.domain.com/sdk",
      "dc_name": "dc1",
      "username": "root",
      "password": "{{user `vsphere_password`}}",

      "template": "ubuntu",
      "folder_name": "folder",
      "vm_name": "vm-1",
      "host": "esxi-1.domain.com",
      "resource_pool": "pool1/pool2",
      "datastore": "datastore1",
      "linked_clone": true,

      "cpus": 2,
      "ram": 8192,

      "ssh_username": "root",
      "ssh_password": "{{user `guest_password`}}",

      "shutdown_command": "echo '{{user `guest_password`}}' | sudo -S shutdown -P now",
      "create_snapshot": true,
      "convert_to_template": true
    }
  ],

  "provisioners": [
    {
      "type": "shell",
      "environment_vars": [
        "DEBIAN_FRONTEND=noninteractive"
      ],
      "execute_command": "echo '{{user `guest_password`}}' | {{.Vars}} sudo -ES bash -eux '{{.Path}}'",
      "inline": [
        "apt-get install -y zip"
      ]
    }
  ]
}