Terraform-VMWare-Modules / terraform-vsphere-vm

Terraform vSphere module for provisioning Virtual Machines
https://registry.terraform.io/modules/Terraform-VMWare-Modules/vm/vsphere/
MIT License
169 stars 175 forks source link

Handle new vmrpid variable #139

Closed lgatellier closed 1 year ago

lgatellier commented 2 years ago

Add new vmrpid variable to allow users to provide a resource pool id instead of a resource pool path.

This can be used, for exemple, to link the vSphere VM to a vsphere_vapp_container also managed by terraform.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

lgatellier commented 1 year ago

Hi,

This PR is not stale, but awaits some review from the project contributors. Someone here to take a look ? @Arman-Keyoumarsi maybe ?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

lgatellier commented 1 year ago

Not stale yet. Any contributor here ? @sestegra @LennertMertens @keachi @dstoffel-de @riccardo-salamanna @alexjfisher @gunnypatel @bcorner13 @mordekasg @vladdoster

vladdoster commented 1 year ago

@lgatellier I'll volunteer to review.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

lgatellier commented 1 year ago

Some news, here? 🙂

Arman-Keyoumarsi commented 1 year ago

Hi @lgatellier

Sorry for the late response. The code looks good but can you please provide the sanity and smoke test result to make sure it is not breaking any other part of the module?

Thanks

lgatellier commented 1 year ago

@Arman-Keyoumarsi thanks a lot for your review !

Here are the sanity test vars :

viserver   = "<sensitive>"
viuser     = "<sensitive>"
vipassword = "<sensitive>"

vm = {
  linuxvm = {
    vmname           = "sanitylinuxvm"
    vmtemp           = "<linux_template_name",
    is_windows_image = false
    vmrp             = "<esxi_cluster_name>/Resources"
    dc               = "<dc_name>",
    datastore        = "<datastore_name>"
    vmfolder         = ""
    vmgateway        = "10.13.13.1"
    dns_servers      = ["1.1.1.1"]
    network = {
      "prod-510" = ["10.13.13.2", ""] # To use DHCP create Empty list for each instance
    }
  },
  windowsvm = {
    vmname           = "sanitywindowsvm"
    vmtemp           = "<windows_template_name>"
    is_windows_image = true
    vmrp             = "<cluster_name>/Resources"
    dc               = "<dc_name>"
    vmfolder         = ""
    datastore        = "<datastore_name>"
    dns_servers      = null
    vmgateway        = "10.13.13.1"
    network = {
      "prod-510" = ["10.13.13.2", ""] # To use DHCP create Empty list for each instance
    }
  }
}

Plan : NB : I made a little change to main.tf to avoid errors dues to my template which already has 2 disks (conflict with sanity/main.tf:disk1, and missing I/O settings 2nd array item).

Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of hashicorp/vsphere from the dependency lock file
- Using previously-installed hashicorp/vsphere v2.0.0

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Success! The configuration is valid.

module.example-server-basic["windowsvm"].data.vsphere_datacenter.dc: Reading...
module.example-server-basic["linuxvm"].data.vsphere_datacenter.dc: Reading...
module.example-server-basic["linuxvm"].data.vsphere_datacenter.dc: Read complete after 0s [id=datacenter-2]
module.example-server-basic["windowsvm"].data.vsphere_datacenter.dc: Read complete after 0s [id=datacenter-2]
module.example-server-basic["windowsvm"].data.vsphere_folder.folder[0]: Reading...
module.example-server-basic["windowsvm"].data.vsphere_network.network[0]: Reading...
module.example-server-basic["linuxvm"].data.vsphere_virtual_machine.template[0]: Reading...
module.example-server-basic["linuxvm"].data.vsphere_folder.folder[0]: Reading...
module.example-server-basic["linuxvm"].data.vsphere_network.network[0]: Reading...
module.example-server-basic["windowsvm"].data.vsphere_datastore.datastore[0]: Reading...
module.example-server-basic["linuxvm"].data.vsphere_resource_pool.pool: Reading...
module.example-server-basic["linuxvm"].data.vsphere_datastore.datastore[0]: Reading...
module.example-server-basic["windowsvm"].data.vsphere_virtual_machine.template[0]: Reading...
module.example-server-basic["windowsvm"].data.vsphere_resource_pool.pool: Reading...
module.example-server-basic["linuxvm"].data.vsphere_folder.folder[0]: Read complete after 0s [id=group-v3]
module.example-server-basic["windowsvm"].data.vsphere_folder.folder[0]: Read complete after 0s [id=group-v3]
module.example-server-basic["linuxvm"].data.vsphere_network.network[0]: Read complete after 0s [id=network-31]
module.example-server-basic["windowsvm"].data.vsphere_network.network[0]: Read complete after 0s [id=network-31]
module.example-server-basic["linuxvm"].data.vsphere_resource_pool.pool: Read complete after 0s [id=resgroup-8]
module.example-server-basic["windowsvm"].data.vsphere_resource_pool.pool: Read complete after 0s [id=resgroup-8]
module.example-server-basic["linuxvm"].data.vsphere_datastore.datastore[0]: Read complete after 0s [id=datastore-427089]
module.example-server-basic["windowsvm"].data.vsphere_datastore.datastore[0]: Read complete after 0s [id=datastore-427089]
module.example-server-basic["linuxvm"].data.vsphere_virtual_machine.template[0]: Read complete after 0s [id=423f1fed-9f63-d88c-7bd9-f1febcc33b60]
module.example-server-basic["windowsvm"].data.vsphere_virtual_machine.template[0]: Read complete after 0s [id=423fc9c8-665b-29fc-5a3d-eebe5afac7e4]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
 <= read (data resources)

Terraform will perform the following actions:

  # vsphere_tag.tag will be created
  + resource "vsphere_tag" "tag" {
      + category_id = (known after apply)
      + description = "Managed by Terraform"
      + id          = (known after apply)
      + name        = "terraform-test-tag"
    }

  # vsphere_tag_category.category will be created
  + resource "vsphere_tag_category" "category" {
      + associable_types = [
          + "Datastore",
          + "VirtualMachine",
        ]
      + cardinality      = "SINGLE"
      + description      = "Managed by Terraform"
      + id               = (known after apply)
      + name             = "terraform-test-category"
    }

  # module.example-server-basic["linuxvm"].data.vsphere_tag.tag[0] will be read during apply
  # (config refers to values not yet known)
 <= data "vsphere_tag" "tag" {
      + category_id = (known after apply)
      + description = (known after apply)
      + id          = (known after apply)
      + name        = "terraform-test-tag"
    }

  # module.example-server-basic["linuxvm"].data.vsphere_tag_category.category[0] will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "vsphere_tag_category" "category" {
      + associable_types = (known after apply)
      + cardinality      = (known after apply)
      + description      = (known after apply)
      + id               = (known after apply)
      + name             = "terraform-test-category"
    }

  # module.example-server-basic["linuxvm"].vsphere_virtual_machine.vm[0] will be created
  + resource "vsphere_virtual_machine" "vm" {
      + annotation                              = "Terraform Sanity Test"
      + boot_retry_delay                        = 10000
      + change_version                          = (known after apply)
      + cpu_limit                               = -1
      + cpu_share_count                         = 2000
      + cpu_share_level                         = "custom"
      + datastore_id                            = "datastore-427089"
      + default_ip_address                      = (known after apply)
      + efi_secure_boot_enabled                 = false
      + enable_disk_uuid                        = false
      + ept_rvi_mode                            = "automatic"
      + firmware                                = "bios"
      + force_power_off                         = true
      + guest_id                                = "centos8_64Guest"
      + guest_ip_addresses                      = (known after apply)
      + hardware_version                        = (known after apply)
      + host_system_id                          = (known after apply)
      + hv_mode                                 = "hvAuto"
      + id                                      = (known after apply)
      + ide_controller_count                    = 2
      + ignored_guest_ips                       = []
      + imported                                = (known after apply)
      + latency_sensitivity                     = "normal"
      + memory                                  = 4096
      + memory_limit                            = -1
      + memory_share_count                      = 2000
      + memory_share_level                      = "custom"
      + migrate_wait_timeout                    = 30
      + moid                                    = (known after apply)
      + name                                    = "terraform-sanitytest001dev.somedomain.com"
      + num_cores_per_socket                    = 1
      + num_cpus                                = 2
      + poweron_timeout                         = 300
      + reboot_required                         = (known after apply)
      + resource_pool_id                        = "resgroup-8"
      + run_tools_scripts_after_power_on        = true
      + run_tools_scripts_after_resume          = true
      + run_tools_scripts_before_guest_shutdown = true
      + run_tools_scripts_before_guest_standby  = true
      + sata_controller_count                   = 0
      + scsi_bus_sharing                        = "noSharing"
      + scsi_controller_count                   = 2
      + scsi_type                               = "lsilogic"
      + shutdown_wait_timeout                   = 3
      + storage_policy_id                       = (known after apply)
      + swap_placement_policy                   = "inherit"
      + tags                                    = (known after apply)
      + uuid                                    = (known after apply)
      + vapp_transport                          = (known after apply)
      + vmware_tools_status                     = (known after apply)
      + vmx_path                                = (known after apply)
      + wait_for_guest_ip_timeout               = 0
      + wait_for_guest_net_routable             = true
      + wait_for_guest_net_timeout              = 5

      + clone {
          + linked_clone  = false
          + template_uuid = "423f1fed-9f63-d88c-7bd9-f1febcc33b60"
          + timeout       = 30

          + customize {
              + ipv4_gateway = "10.13.13.1"
              + timeout      = 10

              + linux_options {
                  + domain       = "Development.com"
                  + host_name    = "terraform-sanitytest001dev.somedomain.com"
                  + hw_clock_utc = true
                }

              + network_interface {
                  + ipv4_address = "10.13.13.2"
                  + ipv4_netmask = 24
                }
            }
        }

      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "disk0"
          + path              = (known after apply)
          + size              = 40
          + storage_policy_id = (known after apply)
          + thin_provisioned  = true
          + unit_number       = 0
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "disk1"
          + path              = (known after apply)
          + size              = 10
          + storage_policy_id = (known after apply)
          + thin_provisioned  = true
          + unit_number       = 1
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 0
          + io_share_count    = 0
          + io_share_level    = "normal"
          + keep_on_remove    = false
          + key               = 0
          + label             = "diskalpha"
          + path              = (known after apply)
          + size              = 30
          + storage_policy_id = "ff45cc66-b624-4621-967f-1aef6437f568"
          + thin_provisioned  = false
          + unit_number       = 2
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "diskbeta"
          + path              = (known after apply)
          + size              = 70
          + storage_policy_id = (known after apply)
          + thin_provisioned  = true
          + unit_number       = 16
          + uuid              = (known after apply)
          + write_through     = false
        }

      + network_interface {
          + adapter_type          = "vmxnet3"
          + bandwidth_limit       = -1
          + bandwidth_reservation = 0
          + bandwidth_share_count = (known after apply)
          + bandwidth_share_level = "normal"
          + device_address        = (known after apply)
          + key                   = (known after apply)
          + mac_address           = (known after apply)
          + network_id            = "network-31"
        }
    }

  # module.example-server-basic["linuxvm"].vsphere_virtual_machine.vm[1] will be created
  + resource "vsphere_virtual_machine" "vm" {
      + annotation                              = "Terraform Sanity Test"
      + boot_retry_delay                        = 10000
      + change_version                          = (known after apply)
      + cpu_limit                               = -1
      + cpu_share_count                         = 2000
      + cpu_share_level                         = "custom"
      + datastore_id                            = "datastore-427089"
      + default_ip_address                      = (known after apply)
      + efi_secure_boot_enabled                 = false
      + enable_disk_uuid                        = false
      + ept_rvi_mode                            = "automatic"
      + firmware                                = "bios"
      + force_power_off                         = true
      + guest_id                                = "centos8_64Guest"
      + guest_ip_addresses                      = (known after apply)
      + hardware_version                        = (known after apply)
      + host_system_id                          = (known after apply)
      + hv_mode                                 = "hvAuto"
      + id                                      = (known after apply)
      + ide_controller_count                    = 2
      + ignored_guest_ips                       = []
      + imported                                = (known after apply)
      + latency_sensitivity                     = "normal"
      + memory                                  = 4096
      + memory_limit                            = -1
      + memory_share_count                      = 2000
      + memory_share_level                      = "custom"
      + migrate_wait_timeout                    = 30
      + moid                                    = (known after apply)
      + name                                    = "terraform-sanitytest002dev.somedomain.com"
      + num_cores_per_socket                    = 1
      + num_cpus                                = 2
      + poweron_timeout                         = 300
      + reboot_required                         = (known after apply)
      + resource_pool_id                        = "resgroup-8"
      + run_tools_scripts_after_power_on        = true
      + run_tools_scripts_after_resume          = true
      + run_tools_scripts_before_guest_shutdown = true
      + run_tools_scripts_before_guest_standby  = true
      + sata_controller_count                   = 0
      + scsi_bus_sharing                        = "noSharing"
      + scsi_controller_count                   = 2
      + scsi_type                               = "lsilogic"
      + shutdown_wait_timeout                   = 3
      + storage_policy_id                       = (known after apply)
      + swap_placement_policy                   = "inherit"
      + tags                                    = (known after apply)
      + uuid                                    = (known after apply)
      + vapp_transport                          = (known after apply)
      + vmware_tools_status                     = (known after apply)
      + vmx_path                                = (known after apply)
      + wait_for_guest_ip_timeout               = 0
      + wait_for_guest_net_routable             = true
      + wait_for_guest_net_timeout              = 5

      + clone {
          + linked_clone  = false
          + template_uuid = "423f1fed-9f63-d88c-7bd9-f1febcc33b60"
          + timeout       = 30

          + customize {
              + ipv4_gateway = "10.13.13.1"
              + timeout      = 10

              + linux_options {
                  + domain       = "Development.com"
                  + host_name    = "terraform-sanitytest002dev.somedomain.com"
                  + hw_clock_utc = true
                }

              + network_interface {}
            }
        }

      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "disk0"
          + path              = (known after apply)
          + size              = 40
          + storage_policy_id = (known after apply)
          + thin_provisioned  = true
          + unit_number       = 0
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "disk1"
          + path              = (known after apply)
          + size              = 10
          + storage_policy_id = (known after apply)
          + thin_provisioned  = true
          + unit_number       = 1
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 0
          + io_share_count    = 0
          + io_share_level    = "normal"
          + keep_on_remove    = false
          + key               = 0
          + label             = "diskalpha"
          + path              = (known after apply)
          + size              = 30
          + storage_policy_id = "ff45cc66-b624-4621-967f-1aef6437f568"
          + thin_provisioned  = false
          + unit_number       = 2
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "diskbeta"
          + path              = (known after apply)
          + size              = 70
          + storage_policy_id = (known after apply)
          + thin_provisioned  = true
          + unit_number       = 16
          + uuid              = (known after apply)
          + write_through     = false
        }

      + network_interface {
          + adapter_type          = "vmxnet3"
          + bandwidth_limit       = -1
          + bandwidth_reservation = 0
          + bandwidth_share_count = (known after apply)
          + bandwidth_share_level = "normal"
          + device_address        = (known after apply)
          + key                   = (known after apply)
          + mac_address           = (known after apply)
          + network_id            = "network-31"
        }
    }

  # module.example-server-basic["windowsvm"].data.vsphere_tag.tag[0] will be read during apply
  # (config refers to values not yet known)
 <= data "vsphere_tag" "tag" {
      + category_id = (known after apply)
      + description = (known after apply)
      + id          = (known after apply)
      + name        = "terraform-test-tag"
    }

  # module.example-server-basic["windowsvm"].data.vsphere_tag_category.category[0] will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "vsphere_tag_category" "category" {
      + associable_types = (known after apply)
      + cardinality      = (known after apply)
      + description      = (known after apply)
      + id               = (known after apply)
      + name             = "terraform-test-category"
    }

  # module.example-server-basic["windowsvm"].vsphere_virtual_machine.vm[0] will be created
  + resource "vsphere_virtual_machine" "vm" {
      + annotation                              = "Terraform Sanity Test"
      + boot_retry_delay                        = 10000
      + change_version                          = (known after apply)
      + cpu_limit                               = -1
      + cpu_share_count                         = 2000
      + cpu_share_level                         = "custom"
      + datastore_id                            = "datastore-427089"
      + default_ip_address                      = (known after apply)
      + efi_secure_boot_enabled                 = true
      + enable_disk_uuid                        = true
      + ept_rvi_mode                            = "automatic"
      + firmware                                = "efi"
      + force_power_off                         = true
      + guest_id                                = "windows9Server64Guest"
      + guest_ip_addresses                      = (known after apply)
      + hardware_version                        = (known after apply)
      + host_system_id                          = (known after apply)
      + hv_mode                                 = "hvAuto"
      + id                                      = (known after apply)
      + ide_controller_count                    = 2
      + ignored_guest_ips                       = []
      + imported                                = (known after apply)
      + latency_sensitivity                     = "normal"
      + memory                                  = 4096
      + memory_limit                            = -1
      + memory_share_count                      = 2000
      + memory_share_level                      = "custom"
      + migrate_wait_timeout                    = 30
      + moid                                    = (known after apply)
      + name                                    = "terraform-sanitytest001dev.somedomain.com"
      + num_cores_per_socket                    = 1
      + num_cpus                                = 2
      + poweron_timeout                         = 300
      + reboot_required                         = (known after apply)
      + resource_pool_id                        = "resgroup-8"
      + run_tools_scripts_after_power_on        = true
      + run_tools_scripts_after_resume          = true
      + run_tools_scripts_before_guest_shutdown = true
      + run_tools_scripts_before_guest_standby  = true
      + sata_controller_count                   = 0
      + scsi_bus_sharing                        = "noSharing"
      + scsi_controller_count                   = 2
      + scsi_type                               = "lsilogic-sas"
      + shutdown_wait_timeout                   = 3
      + storage_policy_id                       = (known after apply)
      + swap_placement_policy                   = "inherit"
      + tags                                    = (known after apply)
      + uuid                                    = (known after apply)
      + vapp_transport                          = (known after apply)
      + vmware_tools_status                     = (known after apply)
      + vmx_path                                = (known after apply)
      + wait_for_guest_ip_timeout               = 0
      + wait_for_guest_net_routable             = true
      + wait_for_guest_net_timeout              = 5

      + clone {
          + linked_clone  = false
          + template_uuid = "423fc9c8-665b-29fc-5a3d-eebe5afac7e4"
          + timeout       = 30

          + customize {
              + ipv4_gateway = "10.13.13.1"
              + timeout      = 10

              + network_interface {
                  + ipv4_address = "10.13.13.2"
                  + ipv4_netmask = 24
                }

              + windows_options {
                  + auto_logon_count  = 1
                  + computer_name     = "terraform-sanitytest001dev.somedomain.com"
                  + full_name         = "Administrator"
                  + organization_name = "Managed by Terraform"
                  + time_zone         = 85
                }
            }
        }

      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = true
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "disk0"
          + path              = (known after apply)
          + size              = 80
          + storage_policy_id = (known after apply)
          + thin_provisioned  = false
          + unit_number       = 0
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 0
          + io_share_count    = 0
          + io_share_level    = "normal"
          + keep_on_remove    = false
          + key               = 0
          + label             = "diskalpha"
          + path              = (known after apply)
          + size              = 30
          + storage_policy_id = "ff45cc66-b624-4621-967f-1aef6437f568"
          + thin_provisioned  = false
          + unit_number       = 1
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "diskbeta"
          + path              = (known after apply)
          + size              = 70
          + storage_policy_id = (known after apply)
          + thin_provisioned  = true
          + unit_number       = 16
          + uuid              = (known after apply)
          + write_through     = false
        }

      + network_interface {
          + adapter_type          = "e1000e"
          + bandwidth_limit       = -1
          + bandwidth_reservation = 0
          + bandwidth_share_count = (known after apply)
          + bandwidth_share_level = "normal"
          + device_address        = (known after apply)
          + key                   = (known after apply)
          + mac_address           = (known after apply)
          + network_id            = "network-31"
        }
    }

  # module.example-server-basic["windowsvm"].vsphere_virtual_machine.vm[1] will be created
  + resource "vsphere_virtual_machine" "vm" {
      + annotation                              = "Terraform Sanity Test"
      + boot_retry_delay                        = 10000
      + change_version                          = (known after apply)
      + cpu_limit                               = -1
      + cpu_share_count                         = 2000
      + cpu_share_level                         = "custom"
      + datastore_id                            = "datastore-427089"
      + default_ip_address                      = (known after apply)
      + efi_secure_boot_enabled                 = true
      + enable_disk_uuid                        = true
      + ept_rvi_mode                            = "automatic"
      + firmware                                = "efi"
      + force_power_off                         = true
      + guest_id                                = "windows9Server64Guest"
      + guest_ip_addresses                      = (known after apply)
      + hardware_version                        = (known after apply)
      + host_system_id                          = (known after apply)
      + hv_mode                                 = "hvAuto"
      + id                                      = (known after apply)
      + ide_controller_count                    = 2
      + ignored_guest_ips                       = []
      + imported                                = (known after apply)
      + latency_sensitivity                     = "normal"
      + memory                                  = 4096
      + memory_limit                            = -1
      + memory_share_count                      = 2000
      + memory_share_level                      = "custom"
      + migrate_wait_timeout                    = 30
      + moid                                    = (known after apply)
      + name                                    = "terraform-sanitytest002dev.somedomain.com"
      + num_cores_per_socket                    = 1
      + num_cpus                                = 2
      + poweron_timeout                         = 300
      + reboot_required                         = (known after apply)
      + resource_pool_id                        = "resgroup-8"
      + run_tools_scripts_after_power_on        = true
      + run_tools_scripts_after_resume          = true
      + run_tools_scripts_before_guest_shutdown = true
      + run_tools_scripts_before_guest_standby  = true
      + sata_controller_count                   = 0
      + scsi_bus_sharing                        = "noSharing"
      + scsi_controller_count                   = 2
      + scsi_type                               = "lsilogic-sas"
      + shutdown_wait_timeout                   = 3
      + storage_policy_id                       = (known after apply)
      + swap_placement_policy                   = "inherit"
      + tags                                    = (known after apply)
      + uuid                                    = (known after apply)
      + vapp_transport                          = (known after apply)
      + vmware_tools_status                     = (known after apply)
      + vmx_path                                = (known after apply)
      + wait_for_guest_ip_timeout               = 0
      + wait_for_guest_net_routable             = true
      + wait_for_guest_net_timeout              = 5

      + clone {
          + linked_clone  = false
          + template_uuid = "423fc9c8-665b-29fc-5a3d-eebe5afac7e4"
          + timeout       = 30

          + customize {
              + ipv4_gateway = "10.13.13.1"
              + timeout      = 10

              + network_interface {}

              + windows_options {
                  + auto_logon_count  = 1
                  + computer_name     = "terraform-sanitytest002dev.somedomain.com"
                  + full_name         = "Administrator"
                  + organization_name = "Managed by Terraform"
                  + time_zone         = 85
                }
            }
        }

      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = true
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "disk0"
          + path              = (known after apply)
          + size              = 80
          + storage_policy_id = (known after apply)
          + thin_provisioned  = false
          + unit_number       = 0
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 0
          + io_share_count    = 0
          + io_share_level    = "normal"
          + keep_on_remove    = false
          + key               = 0
          + label             = "diskalpha"
          + path              = (known after apply)
          + size              = 30
          + storage_policy_id = "ff45cc66-b624-4621-967f-1aef6437f568"
          + thin_provisioned  = false
          + unit_number       = 1
          + uuid              = (known after apply)
          + write_through     = false
        }
      + disk {
          + attach            = false
          + controller_type   = "scsi"
          + datastore_id      = "<computed>"
          + device_address    = (known after apply)
          + disk_mode         = "persistent"
          + disk_sharing      = "sharingNone"
          + eagerly_scrub     = false
          + io_limit          = -1
          + io_reservation    = 15
          + io_share_count    = 2000
          + io_share_level    = "custom"
          + keep_on_remove    = false
          + key               = 0
          + label             = "diskbeta"
          + path              = (known after apply)
          + size              = 70
          + storage_policy_id = (known after apply)
          + thin_provisioned  = true
          + unit_number       = 16
          + uuid              = (known after apply)
          + write_through     = false
        }

      + network_interface {
          + adapter_type          = "e1000e"
          + bandwidth_limit       = -1
          + bandwidth_reservation = 0
          + bandwidth_share_count = (known after apply)
          + bandwidth_share_level = "normal"
          + device_address        = (known after apply)
          + key                   = (known after apply)
          + mac_address           = (known after apply)
          + network_id            = "network-31"
        }
    }

Plan: 6 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + DC_ID = {
      + "linuxvm"   = "datacenter-2"
      + "windowsvm" = "datacenter-2"
    }
  + VM    = {
      + "linuxvm"   = [
          + "terraform-sanitytest001dev.somedomain.com",
          + "terraform-sanitytest002dev.somedomain.com",
        ]
      + "windowsvm" = [
          + "terraform-sanitytest001dev.somedomain.com",
          + "terraform-sanitytest002dev.somedomain.com",
        ]
    }

─────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't
guarantee to take exactly these actions if you run "terraform apply" now.

Smoke tests vars :

viserver   = "<sensitive>"
viuser     = "<sensitive>"
vipassword = "<sensitive>"

vm = {
  linuxvm = {
    vmname           = "sanitylinuxvm"
    vmtemp           = "<template_name>",
    content_library  = null
    annotation       = "Terraform Smoke Test"
    instances        = 0
    is_windows_image = false
    vmrp             = "<cluster_name>/Resources"
    dc               = "<dc_name>",
    datastore        = "<datastore_name>"
    vmfolder         = ""
    vmgateway        = "10.13.13.1"
    dns_servers      = ["1.1.1.1"]
    network = {
      "prod-510" = ["10.13.13.2"] # To use DHCP create Empty list for each instance
    }
    disk_size_gb = [60, 10]
  }
}

And plan :

Initializing modules...
- example-server-basic in ../..

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of hashicorp/vsphere from the dependency lock file
- Installing hashicorp/vsphere v1.24.2...
- Installed hashicorp/vsphere v1.24.2 (signed by HashiCorp)

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
private.tfvars
Success! The configuration is valid.

module.example-server-basic["linuxvm"].data.vsphere_datacenter.dc: Reading...
module.example-server-basic["linuxvm"].data.vsphere_datacenter.dc: Read complete after 0s [id=datacenter-2]
module.example-server-basic["linuxvm"].data.vsphere_virtual_machine.template[0]: Reading...
module.example-server-basic["linuxvm"].data.vsphere_resource_pool.pool: Reading...
module.example-server-basic["linuxvm"].data.vsphere_folder.folder[0]: Reading...
module.example-server-basic["linuxvm"].data.vsphere_network.network[0]: Reading...
module.example-server-basic["linuxvm"].data.vsphere_datastore.datastore[0]: Reading...
module.example-server-basic["linuxvm"].data.vsphere_folder.folder[0]: Read complete after 0s [id=group-v3]
module.example-server-basic["linuxvm"].data.vsphere_network.network[0]: Read complete after 0s [id=network-31]
module.example-server-basic["linuxvm"].data.vsphere_resource_pool.pool: Read complete after 0s [id=resgroup-8]
module.example-server-basic["linuxvm"].data.vsphere_datastore.datastore[0]: Read complete after 0s [id=datastore-427089]
module.example-server-basic["linuxvm"].data.vsphere_virtual_machine.template[0]: Read complete after 0s [id=423f1fed-9f63-d88c-7bd9-f1febcc33b60]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

lgatellier commented 1 year ago

Hi, This PR is not stale 🙂

Arman-Keyoumarsi commented 1 year ago

Thanks :)