Add `insecure_connection` parameter

This commit is contained in:
Michael Kuzmin 2017-07-01 18:59:36 +03:00
parent d12fbcb700
commit b218d42895
4 changed files with 8 additions and 5 deletions

View File

@ -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:

View File

@ -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
}

View File

@ -20,6 +20,7 @@ const testBuilderAccBasic = `
"vcenter_server": "vcenter.vsphere5.test",
"username": "root",
"password": "jetbrains",
"insecure_connection": true,
"template": "basic",
"vm_name": "test1",

View File

@ -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"`