Skip to content

Commit 392c0a9

Browse files
committed
feat: add remote ovf/ova source support
Extends the `vsphere-clone` builder to support using remote OVF and OVA files as clone sources, in addition to the current support for standard virtual machine templates. Remote OVF/OVA support enables users to deploy virtual machines directly from OVF/OVA files accessible via HTTP/HTTPS URLs using vSphere's native OVF Manager capabilities available in the `vmware/govmomi` SDK. Signed-off-by: Ryan Johnson <ryan@tenthirtyam.otg>
1 parent c9b267b commit 392c0a9

20 files changed

+7946
-13
lines changed

.web-docs/components/builder/vsphere-clone/README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ references, which are necessary for a build to succeed and can be found further
6161

6262
- `template` (string) - The name of the source virtual machine to clone.
6363

64+
- `remote_source` (\*RemoteSourceConfig) - Configuration for cloning from a remote OVF/OVA source.
65+
Cannot be used together with `template`.
66+
67+
For more information, refer to the [Remote Source Configuration](/packer/integrations/hashicorp/vmware/latest/components/builder/vsphere-clone#remote-source-configuration)
68+
section.
69+
6470
- `disk_size` (int64) - The size of the primary disk in MiB. Cannot be used with `linked_clone`.
6571
-> **Note:** Only the primary disk size can be specified. Additional
6672
disks are not supported.
@@ -114,6 +120,49 @@ references, which are necessary for a build to succeed and can be found further
114120
<!-- End of code generated from the comments of the StorageConfig struct in builder/vsphere/common/storage_config.go; -->
115121

116122

123+
### Remote Source Configuration
124+
125+
**Optional:**
126+
127+
<!-- Code generated from the comments of the RemoteSourceConfig struct in builder/vsphere/clone/step_clone.go; DO NOT EDIT MANUALLY -->
128+
129+
- `url` (string) - The URL of the remote OVF/OVA file. Supports HTTP and HTTPS protocols.
130+
131+
- `username` (string) - The username for basic authentication when accessing the remote OVF/OVA file.
132+
Must be used together with `password`.
133+
134+
- `password` (string) - The password for basic authentication when accessing the remote OVF/OVA file.
135+
Must be used together with `username`.
136+
137+
- `skip_tls_verify` (bool) - Do not validate the certificate when accessing HTTPS URLs.
138+
Defaults to `false`.
139+
140+
-> **Note:** This option is beneficial in scenarios where the certificate
141+
is self-signed or does not meet standard validation criteria.
142+
143+
HCL Example:
144+
145+
```hcl
146+
remote_source = {
147+
url = "https://packages.example.com/artifacts/example.ovf"
148+
username = "remote_source_username"
149+
password = "remote_source_password"
150+
skip_tls_verify = false
151+
}
152+
```
153+
154+
JSON Example:
155+
```json
156+
"remote_source": {
157+
"url": "https://packages.example.com/artifacts/example.ovf",
158+
"username": "remote_source_username",
159+
"password": "remote_source_password",
160+
"skip_tls_verify": false
161+
}
162+
163+
<!-- End of code generated from the comments of the RemoteSourceConfig struct in builder/vsphere/clone/step_clone.go; -->
164+
165+
117166
### Storage Configuration
118167

119168
When cloning a virtual machine, the storage configuration can be used to add additional storage and
@@ -255,12 +304,14 @@ JSON Example:
255304
property keys that do not exist.
256305

257306
HCL Example:
307+
258308
```hcl
259309
vapp {
260310
properties = {
261311
hostname = var.hostname
262312
user-data = base64encode(var.user_data)
263313
}
314+
deployment_option = "small"
264315
}
265316
```
266317

@@ -271,7 +322,8 @@ JSON Example:
271322
"properties": {
272323
"hostname": "{{ user `hostname`}}",
273324
"user-data": "{{ env `USERDATA`}}"
274-
}
325+
},
326+
"deployment_option": "small"
275327
}
276328
```
277329

@@ -282,6 +334,10 @@ JSON Example:
282334
export USERDATA=$(gzip -c9 <userdata.yaml | { base64 -w0 2>/dev/null || base64; })
283335
```
284336

337+
- `deployment_option` (string) - The deployment configuration to use when deploying from an OVF/OVA file.
338+
This corresponds to deployment configurations defined in an OVF descriptor.
339+
-> **Note:** Only applicable when using remote OVF/OVA sources.
340+
285341
<!-- End of code generated from the comments of the vAppConfig struct in builder/vsphere/clone/step_clone.go; -->
286342

287343

builder/vsphere/clone/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: MPL-2.0
33

44
//go:generate packer-sdc struct-markdown
5-
//go:generate packer-sdc mapstructure-to-hcl2 -type Config
5+
//go:generate packer-sdc mapstructure-to-hcl2 -type Config,RemoteSourceConfig
66

77
package clone
88

@@ -66,7 +66,7 @@ type Config struct {
6666
ctx interpolate.Context
6767
}
6868

69-
func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
69+
func (c *Config) Prepare(raws ...any) ([]string, error) {
7070
err := config.Decode(c, &config.DecodeOpts{
7171
PluginType: common.BuilderId,
7272
Interpolate: true,

builder/vsphere/clone/config.hcl2spec.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)