From b218d42895ecbc535251f7c1ae54fca9400c3cca Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Sat, 1 Jul 2017 18:59:36 +0300 Subject: [PATCH] Add `insecure_connection` parameter --- README.md | 1 + builder.go | 2 +- builder_acc_test.go | 1 + config.go | 9 +++++---- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c09acf77d..ddbeb5a7c 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ This builder uses native vSphere API, and creates virtual machines remotely. * `host` - vSphere host where target VM is created. * `ssh_username` - username in guest OS. * `ssh_password` - password in guest OS. +* `insecure_connection` - do not validate server's TLS certificate. `false` by default. ### Optional Destination: diff --git a/builder.go b/builder.go index 1e28a47a5..479c4c2f0 100644 --- a/builder.go +++ b/builder.go @@ -45,7 +45,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return nil, err } vcenter_url.User = url.UserPassword(b.config.Username, b.config.Password) - client, err := govmomi.NewClient(ctx, vcenter_url,true) + client, err := govmomi.NewClient(ctx, vcenter_url, b.config.InsecureConnection) if err != nil { return nil, err } diff --git a/builder_acc_test.go b/builder_acc_test.go index a0759bd49..58d0fad1a 100644 --- a/builder_acc_test.go +++ b/builder_acc_test.go @@ -20,6 +20,7 @@ const testBuilderAccBasic = ` "vcenter_server": "vcenter.vsphere5.test", "username": "root", "password": "jetbrains", + "insecure_connection": true, "template": "basic", "vm_name": "test1", diff --git a/config.go b/config.go index 1efcf71b8..246447d30 100644 --- a/config.go +++ b/config.go @@ -16,10 +16,11 @@ type Config struct { common.PackerConfig `mapstructure:",squash"` // Connection - VCenterServer string `mapstructure:"vcenter_server"` - Datacenter string `mapstructure:"datacenter"` - Username string `mapstructure:"username"` - Password string `mapstructure:"password"` + VCenterServer string `mapstructure:"vcenter_server"` + Datacenter string `mapstructure:"datacenter"` + Username string `mapstructure:"username"` + Password string `mapstructure:"password"` + InsecureConnection bool `mapstructure:"insecure_connection"` // Location Template string `mapstructure:"template"`