hashicorp / packer-plugin-vsphere

Packer plugin for VMware vSphere Builder
https://www.packer.io/docs/builders/vsphere
Mozilla Public License 2.0
93 stars 91 forks source link

`vsphere-clone`: Add support for multiple SCSI controllers #84

Open ghost opened 3 years ago

ghost commented 3 years ago

This issue was originally opened by @mayankbatra123 as hashicorp/packer#11091. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

So vshpere-clone module of packer allows us to add storage configurations for adding multiple disks. But it also add another scsi controller which is not required in all use cases. Need an additional option to add multiple disk to default disk_controller rather than creating a new. disk_controller = "scsi0" //example

Reproduction Steps

Add Storage configuration block to vshpere-clone module

Similar to this -

 disk_controller_type = ["pvscsi"]
  storage {
    disk_size             = var.secondary_storage.disk_size
    disk_thin_provisioned = var.secondary_storage.disk_thin_provisioned
    disk_eagerly_scrub    = var.secondary_storage.disk_eagerly_scrub
    disk_controller_index = var.secondary_storage.disk_controller_index
  }

Packer version

v1.7.2

Simplified Packer Buildfile

source "vsphere-clone" "vm-base" {
  vcenter_server      = "${var.vcenter_server}"
  datacenter          = "${var.vcenter_datacenter}"
  insecure_connection = "${var.vcenter_insecure_connection}"
  username            = "${var.vsphere_username}"
  password            = "${var.vsphere_password}"

  vm_name             = "${local.target_vm_tag}"
  template            = "${local.upstream_vm_tag}"
  folder              = "${var.target_vm_folder}"
  cluster             = "${var.target_vm_cluster}"
  datastore           = "${var.target_vm_datastore}"
  resource_pool       = "${var.target_vm_resource_pool}"

  **disk_controller_type = ["pvscsi"]**

  CPUs                = "${var.vm_cpus}"
  RAM                 = "${var.vm_ram_mb}"
  NestedHV            = true
  convert_to_template = "${var.vm_generate_template}"
  create_snapshot     = "${var.vm_create_snapshot}"
  linked_clone        = "${var.vm_linked_clone}"

  ssh_password        = "${var.ssh_password}"
  ssh_username        = "${var.ssh_username}"
  storage {
    disk_size             = var.secondary_storage.disk_size
    disk_thin_provisioned = var.secondary_storage.disk_thin_provisioned
    disk_eagerly_scrub    = var.secondary_storage.disk_eagerly_scrub
    disk_controller_index = var.secondary_storage.disk_controller_index
  }
}

Operating system and Environment details

Ubuntu- 20.4

The above configuration does create an additional disk along with another scsi controller. If I remove the disk_controller_type from above configuration it throws an error.

It would be great to add an additional parameter to the configuration such as: disk_controller = "scsi0" // just for example

This will allow the new disk to be mapped to default scsi controller rather than creating a new one. Current--> 0:0, 1:0 -- Expected --> 0:0,0:1

jlundy2 commented 1 year ago

If you're using a pipeline of the following:

  1. Packer build base OS template from ISO
  2. Packer creates a custom template from the base OS template created in step 1
  3. Terraform deploy and customize the custom template created in step 2

You cannot manipulate any disks added in step 2 during deployment in step 3 as the terraform vsphere provider only supports one disk controller.

Hopefully, this context will help get this issue prioritized.