packer-cn/website/source/docs/post-processors/vsphere-template.html.md

115 lines
3.6 KiB
Markdown
Raw Normal View History

2017-07-09 21:45:57 -04:00
---
description: |
2018-10-26 20:02:51 -04:00
The Packer vSphere Template post-processor takes an artifact from the
VMware-iso builder, built on ESXi (i.e. remote) or an artifact from the vSphere
post-processor and allows to mark a VM as a template and leaving it in a path
of choice.
2017-07-09 21:45:57 -04:00
layout: docs
page_title: 'vSphere Template - Post-Processors'
sidebar_current: 'docs-post-processors-vSphere-template'
---
# vSphere Template Post-Processor
Type: `vsphere-template`
2017-07-09 21:45:57 -04:00
2018-10-26 20:02:51 -04:00
The Packer vSphere Template post-processor takes an artifact from the
VMware-iso builder, built on ESXi (i.e. remote) or an artifact from the
[vSphere](/docs/post-processors/vsphere.html) post-processor and allows to mark
a VM as a template and leaving it in a path of choice.
2017-07-09 21:45:57 -04:00
## Example
An example is shown below, showing only the post-processor configuration:
``` json
2017-11-27 20:26:03 -05:00
{
"type": "vsphere-template",
"host": "vcenter.local",
2017-07-18 23:10:05 -04:00
"insecure": true,
"username": "root",
2017-11-27 20:26:03 -05:00
"password": "secret",
2017-07-18 23:10:05 -04:00
"datacenter": "mydatacenter",
2017-11-27 20:26:03 -05:00
"folder": "/packer-templates/os/distro-7"
2017-07-09 21:45:57 -04:00
}
```
## Configuration
There are many configuration options available for the post-processor. They are
segmented below into two categories: required and optional parameters. Within
each category, the available configuration keys are alphabetized.
Required:
2018-10-26 20:02:51 -04:00
- `host` (string) - The vSphere host that contains the VM built by the
vmware-iso.
2017-07-09 21:45:57 -04:00
2018-10-26 20:02:51 -04:00
- `password` (string) - Password to use to authenticate to the vSphere
endpoint.
2017-07-09 21:45:57 -04:00
2018-10-26 20:02:51 -04:00
- `username` (string) - The username to use to authenticate to the vSphere
endpoint.
2017-07-09 21:45:57 -04:00
Optional:
2018-10-26 20:02:51 -04:00
- `datacenter` (string) - If you have more than one, you will need to specify
which one the ESXi used.
2017-07-18 23:10:05 -04:00
2017-11-27 20:26:03 -05:00
- `folder` (string) - Target path where the template will be created.
2018-10-26 20:02:51 -04:00
- `insecure` (boolean) - If it's true skip verification of server
certificate. Default is false
2019-01-11 17:06:15 -05:00
- `keep_input_artifact` (boolean) - Unlike most post-processors, this option
has no effect for vsphere-template. This is because in order for a template
to work, you can't delete the vm that you generate the template from. The
vsphere template post-processor will therefore always preserve the original
vm.
2019-01-11 17:06:15 -05:00
- `snapshot_enable` (boolean) - Create a snapshot before marking as a
2018-11-10 21:14:55 -05:00
template. Default is false
2019-01-11 17:06:15 -05:00
- `snapshot_name` (string) - Name for the snapshot. Required when
`snapshot_enable` is `true`
- `snapshot_description` (string) - Description for the snapshot. Required
when `snapshot_enable` is `true`
2017-09-24 00:42:28 -04:00
## Using the vSphere Template with local builders
2018-10-26 20:02:51 -04:00
Once the [vSphere](/docs/post-processors/vsphere.html) takes an artifact from
the VMware builder and uploads it to a vSphere endpoint, you will likely want
to mark that VM as template. Packer can do this for you automatically using a
sequence definition (a collection of post-processors that are treated as as
single pipeline, see [Post-Processors](/docs/templates/post-processors.html)
for more information):
2017-09-24 00:42:28 -04:00
``` json
{
"post-processors": [
[
{
"type": "vsphere",
...
},
{
"type": "vsphere-template",
...
}
],
{
"type": "...",
...
}
2017-09-24 00:42:28 -04:00
]
}
```
2018-10-26 20:02:51 -04:00
In the example above, the result of each builder is passed through the defined
sequence of post-processors starting with the `vsphere` post-processor which
will upload the artifact to a vSphere endpoint. The resulting artifact is then
passed on to the `vsphere-template` post-processor which handles marking a VM
as a template. Note that the `vsphere` and `vsphere-template` post-processors
are paired together in their own JSON array.