diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go
index 5e2908964..cc5a9673b 100644
--- a/builder/vmware/iso/builder.go
+++ b/builder/vmware/iso/builder.go
@@ -46,13 +46,17 @@ type Config struct {
DiskTypeId string `mapstructure:"disk_type_id"`
Format string `mapstructure:"format"`
+ // cdrom drive
+ CdromAdapterType string `mapstructure:"cdrom_adapter_type"`
+
// platform information
GuestOSType string `mapstructure:"guest_os_type"`
Version string `mapstructure:"version"`
VMName string `mapstructure:"vm_name"`
- // Network type
- Network string `mapstructure:"network"`
+ // Network adapter and type
+ NetworkAdapterType string `mapstructure:"network_adapter_type"`
+ Network string `mapstructure:"network"`
// device presence
Sound bool `mapstructure:"sound"`
diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go
index 4c3eb58ae..0eb753dc8 100644
--- a/builder/vmware/iso/step_create_vmx.go
+++ b/builder/vmware/iso/step_create_vmx.go
@@ -31,8 +31,9 @@ type vmxTemplateData struct {
CDROMType string
CDROMType_MasterSlave string
- Network_Type string
- Network_Device string
+ Network_Type string
+ Network_Device string
+ Network_Adapter string
Sound_Present string
Usb_Present string
@@ -384,6 +385,8 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist
CDROMType: "ide",
CDROMType_MasterSlave: "0",
+ Network_Adapter: "e1000",
+
Sound_Present: map[bool]string{true: "TRUE", false: "FALSE"}[bool(config.Sound)],
Usb_Present: map[bool]string{true: "TRUE", false: "FALSE"}[bool(config.USB)],
@@ -421,6 +424,38 @@ func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multist
templateData.CDROMType_MasterSlave = "0"
}
+ /// Handle the cdrom adapter type. If the disk adapter type and the
+ // cdrom adapter type are the same, then ensure that the cdrom is the
+ // slave device on whatever bus the disk adapter is on.
+ cdromAdapterType := strings.ToLower(config.CdromAdapterType)
+ if cdromAdapterType == diskAdapterType {
+ templateData.CDROMType_MasterSlave = "1"
+ } else {
+ templateData.CDROMType_MasterSlave = "0"
+ }
+
+ switch cdromAdapterType {
+ case "ide":
+ templateData.CDROMType = "ide"
+ case "sata":
+ templateData.SATA_Present = "TRUE"
+ templateData.CDROMType = "sata"
+ case "scsi":
+ templateData.SCSI_Present = "TRUE"
+ templateData.CDROMType = "scsi"
+ default:
+ err := fmt.Errorf("Error procesing VMX template: %s", cdromAdapterType)
+ state.Put("error", err)
+ ui.Error(err.Error())
+ return multistep.ActionHalt
+ }
+
+ /// Assign the network adapter type into the template if one was specified.
+ network_adapter := strings.ToLower(config.NetworkAdapterType)
+ if network_adapter != "" {
+ templateData.Network_Adapter = network_adapter
+ }
+
/// Check the network type that the user specified
network := config.Network
driver := state.Get("driver").(vmwcommon.Driver).GetVmwareDriver()
@@ -600,7 +635,7 @@ ethernet0.displayName = "Ethernet"
ethernet0.linkStatePropagation.enable = "FALSE"
ethernet0.pciSlotNumber = "33"
ethernet0.present = "TRUE"
-ethernet0.virtualDev = "e1000"
+ethernet0.virtualDev = "{{ .Network_Adapter }}"
ethernet0.wakeOnPcktRcv = "FALSE"
extendedConfigFile = "{{ .Name }}.vmxf"
floppy0.present = "FALSE"
diff --git a/website/source/docs/builders/vmware-iso.html.md b/website/source/docs/builders/vmware-iso.html.md
index 0efe03a0f..2f4e3e44f 100644
--- a/website/source/docs/builders/vmware-iso.html.md
+++ b/website/source/docs/builders/vmware-iso.html.md
@@ -140,6 +140,12 @@ builder.
Virtual Disk Manager User's Guide for desktop VMware clients.
For ESXi, refer to the proper ESXi documentation.
+- `cdrom_adapter_type` (string) - The adapter type (or bus) that will be used
+ by the cdrom device. This is chosen by default based on the disk adapter
+ type. VMware tends to lean towards "ide" for the cdrom device unless
+ "sata" is chosen for the disk adapter and so Packer attempts to mirror
+ this logic. This field can be specified as either "ide", "sata", or "scsi".
+
- `disable_vnc` (boolean) - Whether to create a VNC connection or not.
A `boot_command` cannot be used when this is `false`. Defaults to `false`.
@@ -207,6 +213,12 @@ builder.
such as "hostonly", "nat", or "bridged". If the network is not one of these
values, then it is assumed to be a VMware network device. (VMnet0..x)
+- `network_adapter_type` (string) - This is the ethernet adapter type the the
+ virtual machine will be created with. By default the "e1000" network adapter
+ type will be used by Packer. For more information, please consult the
+ Choosing a network adapter for your virtual machine for desktop VMware
+ clients. For ESXi, refer to the proper ESXi documentation.
+
- `output_directory` (string) - This is the path to the directory where the
resulting virtual machine will be created. This may be relative or absolute.
If relative, the path is relative to the working directory when `packer`