Go to file
Elizaveta Tretyakova b3dcaab8b3 Hw customization (#13)
moved all configuration after cloning
2017-05-19 07:44:27 +03:00
docker fix Dockerfile 2017-05-16 08:49:32 +03:00
.gitignore fix Dockerfile 2017-05-16 08:49:32 +03:00
README.md fix Dockerfile 2017-05-16 08:49:32 +03:00
artifact.go Builder (#2) 2017-05-09 17:23:57 +03:00
build.sh Installation scripts 2017-05-15 00:25:50 +03:00
builder.go Hw customization (#13) 2017-05-19 07:44:27 +03:00
config.go Builder (#2) 2017-05-09 17:23:57 +03:00
docker-compose.yml Installation scripts 2017-05-15 00:25:50 +03:00
glide.lock Lock govmomi dependency version 2017-05-16 08:16:12 +03:00
glide.yaml Lock govmomi dependency version 2017-05-16 08:16:12 +03:00
main.go Builder (#2) 2017-05-09 17:23:57 +03:00
step_clone_vm.go Hw customization (#13) 2017-05-19 07:44:27 +03:00
step_configure_hw.go Hw customization (#13) 2017-05-19 07:44:27 +03:00
step_run.go Builder (#2) 2017-05-09 17:23:57 +03:00
step_shutdown.go Builder (#2) 2017-05-09 17:23:57 +03:00

README.md

packer-builder-vsphere

Installation instructions

  1. It is supposed that you already have Go(and Packer), Docker-compose and Glide set.

  2. Download the sourcces from github.com/LizaTretyakova/packer-builder-vsphere

  3. cd to $GOPATH/go/src/github.com/LizaTretyakova/packer-builder-vsphere (or wherever it was downloaded)

  4. Get the dependencies

$ glide install
  1. Build the binaries
$ docker-compose run build
  1. The template for this builder is like following:
{
    "variables": {
            "url": "{{env `YOUR_VSPHERE_URL`}}",
            "username": "{{env `YOUR_VSPHERE_USERNAME`}}",
            "password": "{{env `YOUR_VSPHERE_PASSWORD`}}",
            "ssh_username": "{{env `TEMPLATE_VM_SSH_USERNAME`}}",
            "ssh_password": "{{env `TEMPLATE_VM_SSH_PASSWORD`}}",
            "dc_name": "{{env `TEMPLATE_VM_DATACENTER`}}",
            "template": "{{env `TEMPLATE_VM_NAME`}}"
    },
    "builders": [
        {
            "type": "vsphere",
            "url": "{{user `url`}}",
            "username": "{{user `username`}}",
            "password": "{{user `password`}}",
            "ssh_username": "{{user `ssh_username`}}",
            "ssh_password": "{{user `ssh_password`}}",
            "dc_name": "{{user `dc_name`}}",
            "template": "{{user `template`}}",
            "vm_name": "new_vm_name",
            "RAM": "1024",
            "cpus": "2",
            "shutdown_command": "echo '{{user `ssh_password`}}' | sudo -S shutdown -P now"
        } 
    ],
    "provisioners": [
        {
              "type": "shell",
              "inline": ["echo foo"]
        }
    ]
}

where vm_name, RAM, cpus and shutdown_command are parameters of the new VM. Parameters ssh_*, dc_name (datacenter name) and template (the name of the base VM) are for the base VM, on which you are creating the new one (note, that VMWare Tools should be already installed on this template machine). url, username and password are your vSphere parameters. You need to set the appropriate values in the variables section before proceeding.

  1. Now you can go to the bin/ directory
$ cd ./bin

and try the builder

$ packer build template.json