diff --git a/builder/vsphere/common/step_import_to_content_library.go b/builder/vsphere/common/step_import_to_content_library.go index fba857d76..6df5dc6c0 100644 --- a/builder/vsphere/common/step_import_to_content_library.go +++ b/builder/vsphere/common/step_import_to_content_library.go @@ -63,6 +63,8 @@ type ContentLibraryDestinationConfig struct { Ovf bool `mapstructure:"ovf"` // When set to true, the VM won't be imported to the content library item. Useful for setting to `true` during a build test stage. Defaults to `false`. SkipImport bool `mapstructure:"skip_import"` + // Flags to use for OVF package creation. The supported flags can be obtained using ExportFlag.list. If unset, no flags will be used. Known values: EXTRA_CONFIG, PRESERVE_MAC + OvfFlags []string `mapstructure:"ovf_flags"` } func (c *ContentLibraryDestinationConfig) Prepare(lc *LocationConfig) []error { @@ -171,6 +173,7 @@ func (s *StepImportToContentLibrary) importOvfTemplate(vm *driver.VirtualMachine Spec: vcenter.CreateSpec{ Name: s.ContentLibConfig.Name, Description: s.ContentLibConfig.Description, + Flags: s.ContentLibConfig.OvfFlags, }, Target: vcenter.LibraryTarget{ LibraryID: s.ContentLibConfig.Library, diff --git a/builder/vsphere/common/step_import_to_content_library.hcl2spec.go b/builder/vsphere/common/step_import_to_content_library.hcl2spec.go index 3b5ceacdb..d936e1be8 100644 --- a/builder/vsphere/common/step_import_to_content_library.hcl2spec.go +++ b/builder/vsphere/common/step_import_to_content_library.hcl2spec.go @@ -10,17 +10,18 @@ import ( // FlatContentLibraryDestinationConfig is an auto-generated flat version of ContentLibraryDestinationConfig. // Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. type FlatContentLibraryDestinationConfig struct { - Library *string `mapstructure:"library" cty:"library" hcl:"library"` - Name *string `mapstructure:"name" cty:"name" hcl:"name"` - Description *string `mapstructure:"description" cty:"description" hcl:"description"` - Cluster *string `mapstructure:"cluster" cty:"cluster" hcl:"cluster"` - Folder *string `mapstructure:"folder" cty:"folder" hcl:"folder"` - Host *string `mapstructure:"host" cty:"host" hcl:"host"` - ResourcePool *string `mapstructure:"resource_pool" cty:"resource_pool" hcl:"resource_pool"` - Datastore *string `mapstructure:"datastore" cty:"datastore" hcl:"datastore"` - Destroy *bool `mapstructure:"destroy" cty:"destroy" hcl:"destroy"` - Ovf *bool `mapstructure:"ovf" cty:"ovf" hcl:"ovf"` - SkipImport *bool `mapstructure:"skip_import" cty:"skip_import" hcl:"skip_import"` + Library *string `mapstructure:"library" cty:"library" hcl:"library"` + Name *string `mapstructure:"name" cty:"name" hcl:"name"` + Description *string `mapstructure:"description" cty:"description" hcl:"description"` + Cluster *string `mapstructure:"cluster" cty:"cluster" hcl:"cluster"` + Folder *string `mapstructure:"folder" cty:"folder" hcl:"folder"` + Host *string `mapstructure:"host" cty:"host" hcl:"host"` + ResourcePool *string `mapstructure:"resource_pool" cty:"resource_pool" hcl:"resource_pool"` + Datastore *string `mapstructure:"datastore" cty:"datastore" hcl:"datastore"` + Destroy *bool `mapstructure:"destroy" cty:"destroy" hcl:"destroy"` + Ovf *bool `mapstructure:"ovf" cty:"ovf" hcl:"ovf"` + SkipImport *bool `mapstructure:"skip_import" cty:"skip_import" hcl:"skip_import"` + OvfFlags []string `mapstructure:"ovf_flags" cty:"ovf_flags" hcl:"ovf_flags"` } // FlatMapstructure returns a new FlatContentLibraryDestinationConfig. @@ -46,6 +47,7 @@ func (*FlatContentLibraryDestinationConfig) HCL2Spec() map[string]hcldec.Spec { "destroy": &hcldec.AttrSpec{Name: "destroy", Type: cty.Bool, Required: false}, "ovf": &hcldec.AttrSpec{Name: "ovf", Type: cty.Bool, Required: false}, "skip_import": &hcldec.AttrSpec{Name: "skip_import", Type: cty.Bool, Required: false}, + "ovf_flags": &hcldec.AttrSpec{Name: "ovf_flags", Type: cty.List(cty.String), Required: false}, } return s } diff --git a/docs-partials/builder/vsphere/common/ContentLibraryDestinationConfig-not-required.mdx b/docs-partials/builder/vsphere/common/ContentLibraryDestinationConfig-not-required.mdx index ca3a4300d..f871d0fd1 100644 --- a/docs-partials/builder/vsphere/common/ContentLibraryDestinationConfig-not-required.mdx +++ b/docs-partials/builder/vsphere/common/ContentLibraryDestinationConfig-not-required.mdx @@ -1,4 +1,4 @@ - + - `library` (string) - Name of the library in which the new library item containing the template should be created/updated. The Content Library should be of type Local to allow deploying virtual machines. @@ -13,7 +13,6 @@ item is necessary, use an OVF template instead by setting the [ovf](#ovf) option as `true`. - `description` (string) - Description of the library item that will be created. - This option is not used when importing OVF templates. Defaults to "Packer imported [vm_name](#vm_name) VM template". - `cluster` (string) - Cluster onto which the virtual machine template should be placed. @@ -23,7 +22,6 @@ Defaults to [cluster](#cluster). - `folder` (string) - Virtual machine folder into which the virtual machine template should be placed. - This option is not used when importing OVF templates. Defaults to the same folder as the source virtual machine. - `host` (string) - Host onto which the virtual machine template should be placed. @@ -47,4 +45,6 @@ - `skip_import` (bool) - When set to true, the VM won't be imported to the content library item. Useful for setting to `true` during a build test stage. Defaults to `false`. - +- `ovf_flags` ([]string) - Flags to use for OVF package creation. The supported flags can be obtained using ExportFlag.list. If unset, no flags will be used. Known values: EXTRA_CONFIG, PRESERVE_MAC + + diff --git a/docs-partials/builder/vsphere/common/ContentLibraryDestinationConfig.mdx b/docs-partials/builder/vsphere/common/ContentLibraryDestinationConfig.mdx index 3e21786a8..4d87e1605 100644 --- a/docs-partials/builder/vsphere/common/ContentLibraryDestinationConfig.mdx +++ b/docs-partials/builder/vsphere/common/ContentLibraryDestinationConfig.mdx @@ -1,7 +1,7 @@ - + With this configuration Packer creates a library item in a content library whose content is a VM template or an OVF template created from the just built VM. The template is stored in a existing or newly created library item. - +