2017-05-14 18:15:24 -04:00
# packer-builder-vsphere
2017-06-23 19:19:44 -04:00
## Usage
* Download the plugin from the [Releases ](https://github.com/jetbrains-infra/packer-builder-vsphere/releases ) page
* [Install ](https://www.packer.io/docs/extending/plugins.html#installing-plugins ) the plugin, or simply save it into the working directory together with a configuration file; you may create your own configuration file or take the one given below (remember to put your real values for names, passwords, `url` and `host` )
2017-06-09 18:44:24 -04:00
``` json
2017-06-23 19:19:44 -04:00
template.json
2017-06-09 18:44:24 -04:00
{
"builders": [
{
"type": "vsphere",
"url": "https://your.lab.addr/",
"username": "username",
"password": "secret",
"ssh_username": "ssh_username",
"ssh_password": "ssh_secret",
"template": "source_vm_name",
"vm_name": "clone_name",
"host": "172.16.0.1"
}
]
}
```
(`host` is for target host)
2017-06-23 19:19:44 -04:00
* Run:
```
$ packer build template.json
```
2017-05-31 05:49:28 -04:00
## Builder parameters
### Required parameters:
* `username`
* `password`
* `template`
* `vm_name`
* `host`
### Optional parameters:
* Destination parameters:
* `resource_pool`
2017-06-09 18:44:24 -04:00
* `datastore`
2017-05-31 05:49:28 -04:00
* Hardware configuration:
* `cpus`
* `ram`
* `shutdown_command`
* `ssh_username`
* `ssh_password`
* `dc_name` (source datacenter)
2017-06-23 19:19:44 -04:00
* Post-processing:
* `linked_clone`
* `to_template`
2017-05-31 05:49:28 -04:00
2017-06-23 19:19:44 -04:00
See an example below:
2017-05-14 18:15:24 -04:00
```json
{
"builders": [
{
"type": "vsphere",
2017-06-23 19:19:44 -04:00
"url": "https://your.lab.addr/",
2017-06-09 18:44:24 -04:00
"username": "username",
"password": "secret",
2017-06-23 19:19:44 -04:00
2017-06-09 18:44:24 -04:00
"ssh_username": "ssh_username",
"ssh_password": "ssh_secret",
2017-06-23 19:19:44 -04:00
"template": "template_name",
"vm_name": "clone_name",
2017-06-09 18:44:24 -04:00
"host": "172.16.0.1",
2017-06-23 19:19:44 -04:00
"linked_clone": true,
"to_template": true,
2017-05-14 18:15:24 -04:00
"RAM": "1024",
"cpus": "2",
2017-06-09 18:44:24 -04:00
"shutdown_command": "echo 'ssh_secret' | sudo -S shutdown -P now"
2017-05-14 18:15:24 -04:00
}
2017-05-14 18:27:14 -04:00
],
"provisioners": [
{
"type": "shell",
"inline": ["echo foo"]
}
2017-05-14 18:15:24 -04:00
]
}
```
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,
2017-05-31 05:40:12 -04:00
on which you are creating the new one (note that VMWare Tools should be already installed on this template machine).
2017-06-23 19:19:44 -04:00
`vm_name` and `host` (describe the name of the new VM and the name of the host where we want to create it) are required parameters; you can also specify `resource_pool` (if you don't, the builder will try to detect the default one) and `datastore` .
2017-05-14 18:15:24 -04:00
`url` , `username` and `password` are your vSphere parameters.
2017-06-23 19:19:44 -04:00
## Progress bar
You can find it [here ](https://github.com/LizaTretyakova/packer-builder-vsphere/projects/1 ) as well.
- [x] hardware customization of the new VM (cpu, ram)
- [x] clone from template (not only from VM)
- [x] clone to alternate host, resource pool and datastore
- [x] enable linked clones
- [ ] support Windows guest systems
- [x] enable VM-to-template conversion
- [ ] tests
- [x] add a shutdown timeout
- [ ] further hardware customization:
* resize disks
* ram reservation
* cpu reservation