While working on cloning virtual machine in vCenter from template I already written two articles Using terraform to clone a virtual machine on VMware vSphere infrastructure and Terraform module clone VMware vSphere Linux and Windows virtual machine. But I wanted to improvise it as I got some modification was required from consumer. Information about new VMs which I was providing earlier in map object format, Instead the data I wanted to get from CSV file.
Below is my csv data.
os,vmname,cpu,memory linux,os-lin1,2,2048 windows,os-win1,2,2048
To get information from csv, create a locals value variable in terraform, Provide csv file path and load using it function file() (${path. module} is a built-in function that gives back the file path of the module where it is being called). Next using csvdecode() to decode csv and convert CSV to map using for loop.
To use this map in module use for_each loop inside module.
locals { csv_data = file("${path.module}/vminfo.csv") #csvdecode(file("vminfo.csv")) vminfo = csvdecode(local.csv_data) vminfo_map = { for vm in local.vminfo : vm.vmname => vm } #covert CSV data to map } module "virtual_machine" { source = "./modules/vsphere_vm" for_each = local.vminfo_map #{ for vm in local.vminfo : vm.vmname => vm } #covert CSV data to map datacenter = "Asgard" cluster = "BiFrost" network = "VM Network" datastore = "StarLord_Datastore01" #Make sure Template is in same datacenter and cluster as mentioned template = each.value.os == "linux" ? "Wakanda_Ubuntu_01" : "Win2019_Template" #["", ""] "" os = each.value.os vmname = each.value.vmname cpu = each.value.cpu memory = each.value.memory }
Download this script Terraform_vCenter_VMClone_from_CSV.zip here or it is also available on github.com.
Below is the output from terraform apply and destroy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
PS C:\Users\demir\OneDrive\Script\Terraform\VMClone_From_Csv> terraform apply --auto-approve module.virtual_machine["os-win1"].data.vsphere_datacenter.datacenter: Reading... module.virtual_machine["os-lin1"].data.vsphere_datacenter.datacenter: Reading... module.virtual_machine["os-win1"].data.vsphere_datacenter.datacenter: Read complete after 0s [id=datacenter-3] module.virtual_machine["os-lin1"].data.vsphere_datacenter.datacenter: Read complete after 0s [id=datacenter-3] module.virtual_machine["os-win1"].data.vsphere_datastore.datastore: Reading... module.virtual_machine["os-lin1"].data.vsphere_compute_cluster.cluster: Reading... module.virtual_machine["os-win1"].data.vsphere_virtual_machine.template: Reading... module.virtual_machine["os-lin1"].data.vsphere_virtual_machine.template: Reading... module.virtual_machine["os-win1"].data.vsphere_network.network: Reading... module.virtual_machine["os-win1"].data.vsphere_compute_cluster.cluster: Reading... module.virtual_machine["os-lin1"].data.vsphere_network.network: Reading... module.virtual_machine["os-lin1"].data.vsphere_datastore.datastore: Reading... module.virtual_machine["os-win1"].data.vsphere_datastore.datastore: Read complete after 1s [id=datastore-3006] module.virtual_machine["os-lin1"].data.vsphere_network.network: Read complete after 0s [id=network-3007] module.virtual_machine["os-lin1"].data.vsphere_datastore.datastore: Read complete after 0s [id=datastore-3006] module.virtual_machine["os-win1"].data.vsphere_compute_cluster.cluster: Read complete after 0s [id=domain-c9] module.virtual_machine["os-win1"].data.vsphere_network.network: Read complete after 0s [id=network-3007] module.virtual_machine["os-lin1"].data.vsphere_compute_cluster.cluster: Read complete after 1s [id=domain-c9] module.virtual_machine["os-lin1"].data.vsphere_virtual_machine.template: Read complete after 1s [id=422a010e-6459-05cb-38fb-6360bbda149b] module.virtual_machine["os-win1"].data.vsphere_virtual_machine.template: Read complete after 1s [id=421cab5b-5c97-2427-2042-57f3c08b3adc] Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0] will be created + resource "vsphere_virtual_machine" "linuxvm" { + annotation = (known after apply) + boot_retry_delay = 10000 + change_version = (known after apply) + cpu_limit = -1 + cpu_share_count = (known after apply) + cpu_share_level = "normal" + datastore_id = "datastore-3006" + default_ip_address = (known after apply) + ept_rvi_mode = "automatic" + extra_config_reboot_required = true + firmware = "efi" + force_power_off = true + guest_id = "ubuntu64Guest" + 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 + imported = (known after apply) + latency_sensitivity = "normal" + memory = 2048 + memory_limit = -1 + memory_share_count = (known after apply) + memory_share_level = "normal" + migrate_wait_timeout = 30 + moid = (known after apply) + name = "os-lin1" + num_cores_per_socket = 1 + num_cpus = 2 + power_state = (known after apply) + poweron_timeout = 300 + reboot_required = (known after apply) + resource_pool_id = "resgroup-10" + 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 = 1 + scsi_type = "lsilogic" + shutdown_wait_timeout = 3 + storage_policy_id = (known after apply) + swap_placement_policy = "inherit" + tools_upgrade_policy = "manual" + 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 { + template_uuid = "422a010e-6459-05cb-38fb-6360bbda149b" + timeout = 30 + customize { + timeout = 10 + linux_options { + domain = "example.com" + host_name = "os-lin1" + 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 = 0 + io_share_count = 0 + io_share_level = "normal" + keep_on_remove = false + key = 0 + label = "os-lin1-disk0" + path = (known after apply) + size = 100 + storage_policy_id = (known after apply) + thin_provisioned = true + unit_number = 0 + uuid = (known after apply) + write_through = false } + network_interface { + adapter_type = "e1000" + 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-3007" } } # module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0] will be created + resource "vsphere_virtual_machine" "windowsvm" { + annotation = (known after apply) + boot_retry_delay = 10000 + change_version = (known after apply) + cpu_limit = -1 + cpu_share_count = (known after apply) + cpu_share_level = "normal" + datastore_id = "datastore-3006" + default_ip_address = (known after apply) + ept_rvi_mode = "automatic" + extra_config_reboot_required = true + firmware = "bios" + force_power_off = true + guest_id = "windows2019srv_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 + imported = (known after apply) + latency_sensitivity = "normal" + memory = 2048 + memory_limit = -1 + memory_share_count = (known after apply) + memory_share_level = "normal" + migrate_wait_timeout = 30 + moid = (known after apply) + name = "os-win1" + num_cores_per_socket = 1 + num_cpus = 2 + power_state = (known after apply) + poweron_timeout = 300 + reboot_required = (known after apply) + resource_pool_id = "resgroup-10" + 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 = 1 + scsi_type = "pvscsi" + shutdown_wait_timeout = 3 + storage_policy_id = (known after apply) + swap_placement_policy = "inherit" + tools_upgrade_policy = "manual" + 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 { + template_uuid = "421cab5b-5c97-2427-2042-57f3c08b3adc" + timeout = 30 + customize { + timeout = 10 + network_interface {} + windows_options { + auto_logon_count = 1 + computer_name = "os-win1" + full_name = "Administrator" + organization_name = "Managed by Terraform" + time_zone = 85 + workgroup = "workgroup" } } } + 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 = "os-win1-disk0" + path = (known after apply) + size = 100 + storage_policy_id = (known after apply) + thin_provisioned = true + unit_number = 0 + 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-3007" } } Plan: 2 to add, 0 to change, 0 to destroy. module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Creating... module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Creating... module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [20s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [30s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [40s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [50s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [1m0s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [1m0s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [1m10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [1m10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [1m20s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [1m20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [1m30s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [1m30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [1m40s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [1m40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [1m50s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [1m50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [2m0s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [2m0s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [2m10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [2m10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [2m20s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [2m20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [2m30s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [2m30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [2m40s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [2m40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [2m50s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [2m50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [3m0s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [3m0s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [3m10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [3m10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [3m20s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [3m20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [3m30s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [3m30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [3m40s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [3m40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [3m50s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [3m50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [4m0s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [4m0s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [4m10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [4m10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [4m20s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [4m20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [4m30s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [4m30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [4m40s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [4m40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [4m50s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [4m50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [5m0s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [5m0s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [5m10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [5m10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [5m20s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [5m20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [5m30s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [5m30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [5m40s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [5m40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [5m50s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [5m50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [6m0s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [6m0s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [6m10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [6m10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [6m20s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [6m20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [6m30s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [6m30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [6m40s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [6m40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [6m50s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [6m50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [7m0s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [7m0s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [7m10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [7m11s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [7m20s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [7m21s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [7m30s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [7m31s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [7m40s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [7m41s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [7m50s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [7m51s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [8m0s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [8m1s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [8m10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [8m11s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [8m20s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [8m21s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [8m30s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [8m31s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [8m40s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [8m41s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [8m50s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [8m51s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [9m0s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [9m1s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [9m10s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still creating... [9m11s elapsed] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Creation complete after 9m19s [id=421c12ae-3839-ea18-56ed-e81b2dc0db49] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [9m20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [9m30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [9m40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [9m50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [10m0s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [10m10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [10m20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [10m30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [10m40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [10m50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [11m0s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [11m10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [11m20s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [11m30s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [11m40s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still creating... [11m50s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Creation complete after 11m58s [id=421c98b8-dbd1-3560-9ead-bd590c9774c6] Apply complete! Resources: 2 added, 0 changed, 0 destroyed. PS C:\Users\demir\OneDrive\Script\Terraform\VMClone_From_Csv> terraform destroy --auto-approve module.virtual_machine["os-lin1"].data.vsphere_datacenter.datacenter: Reading... module.virtual_machine["os-win1"].data.vsphere_datacenter.datacenter: Reading... module.virtual_machine["os-lin1"].data.vsphere_datacenter.datacenter: Read complete after 0s [id=datacenter-3] module.virtual_machine["os-win1"].data.vsphere_datacenter.datacenter: Read complete after 0s [id=datacenter-3] module.virtual_machine["os-lin1"].data.vsphere_network.network: Reading... module.virtual_machine["os-lin1"].data.vsphere_datastore.datastore: Reading... module.virtual_machine["os-win1"].data.vsphere_network.network: Reading... module.virtual_machine["os-win1"].data.vsphere_virtual_machine.template: Reading... module.virtual_machine["os-lin1"].data.vsphere_virtual_machine.template: Reading... module.virtual_machine["os-win1"].data.vsphere_compute_cluster.cluster: Reading... module.virtual_machine["os-win1"].data.vsphere_datastore.datastore: Reading... module.virtual_machine["os-lin1"].data.vsphere_compute_cluster.cluster: Reading... module.virtual_machine["os-lin1"].data.vsphere_datastore.datastore: Read complete after 1s [id=datastore-3006] module.virtual_machine["os-lin1"].data.vsphere_network.network: Read complete after 1s [id=network-3007] module.virtual_machine["os-win1"].data.vsphere_network.network: Read complete after 1s [id=network-3007] module.virtual_machine["os-win1"].data.vsphere_virtual_machine.template: Read complete after 1s [id=421cab5b-5c97-2427-2042-57f3c08b3adc] module.virtual_machine["os-win1"].data.vsphere_datastore.datastore: Read complete after 1s [id=datastore-3006] module.virtual_machine["os-lin1"].data.vsphere_virtual_machine.template: Read complete after 1s [id=422a010e-6459-05cb-38fb-6360bbda149b] module.virtual_machine["os-win1"].data.vsphere_compute_cluster.cluster: Read complete after 1s [id=domain-c9] module.virtual_machine["os-lin1"].data.vsphere_compute_cluster.cluster: Read complete after 1s [id=domain-c9] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Refreshing state... [id=421c12ae-3839-ea18-56ed-e81b2dc0db49] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Refreshing state... [id=421c98b8-dbd1-3560-9ead-bd590c9774c6] Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: - destroy Terraform will perform the following actions: # module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0] will be destroyed - resource "vsphere_virtual_machine" "linuxvm" { - boot_delay = 0 -> null - boot_retry_delay = 10000 -> null - boot_retry_enabled = false -> null - change_version = "2023-07-29T06:14:11.139099Z" -> null - cpu_hot_add_enabled = false -> null - cpu_hot_remove_enabled = false -> null - cpu_limit = -1 -> null - cpu_performance_counters_enabled = false -> null - cpu_reservation = 0 -> null - cpu_share_count = 2000 -> null - cpu_share_level = "normal" -> null - custom_attributes = {} -> null - datastore_id = "datastore-3006" -> null - default_ip_address = "192.168.1.173" -> null - efi_secure_boot_enabled = false -> null - enable_disk_uuid = false -> null - enable_logging = false -> null - extra_config = {} -> null - extra_config_reboot_required = true -> null - firmware = "bios" -> null - force_power_off = true -> null - guest_id = "ubuntu64Guest" -> null - guest_ip_addresses = [ - "192.168.1.173", - "2600:1700:1c00:c230:250:56ff:fe9c:ac0a", - "fe80::250:56ff:fe9c:ac0a", ] -> null - hardware_version = 14 -> null - host_system_id = "host-3003" -> null - id = "421c12ae-3839-ea18-56ed-e81b2dc0db49" -> null - ide_controller_count = 2 -> null - latency_sensitivity = "normal" -> null - memory = 2048 -> null - memory_hot_add_enabled = false -> null - memory_limit = -1 -> null - memory_reservation = 0 -> null - memory_share_count = 20480 -> null - memory_share_level = "normal" -> null - migrate_wait_timeout = 30 -> null - moid = "vm-6003" -> null - name = "os-lin1" -> null - nested_hv_enabled = false -> null - num_cores_per_socket = 1 -> null - num_cpus = 2 -> null - pci_device_id = [] -> null - power_state = "on" -> null - poweron_timeout = 300 -> null - reboot_required = false -> null - resource_pool_id = "resgroup-10" -> null - run_tools_scripts_after_power_on = true -> null - run_tools_scripts_after_resume = true -> null - run_tools_scripts_before_guest_reboot = false -> null - run_tools_scripts_before_guest_shutdown = true -> null - run_tools_scripts_before_guest_standby = true -> null - sata_controller_count = 0 -> null - scsi_bus_sharing = "noSharing" -> null - scsi_controller_count = 1 -> null - scsi_type = "lsilogic" -> null - shutdown_wait_timeout = 3 -> null - swap_placement_policy = "inherit" -> null - sync_time_with_host = false -> null - sync_time_with_host_periodically = false -> null - tags = [] -> null - tools_upgrade_policy = "manual" -> null - uuid = "421c12ae-3839-ea18-56ed-e81b2dc0db49" -> null - vapp_transport = [] -> null - vbs_enabled = false -> null - vmware_tools_status = "guestToolsRunning" -> null - vmx_path = "os-lin1/os-lin1.vmx" -> null - vvtd_enabled = false -> null - wait_for_guest_ip_timeout = 0 -> null - wait_for_guest_net_routable = true -> null - wait_for_guest_net_timeout = 5 -> null - clone { - linked_clone = false -> null - ovf_network_map = {} -> null - ovf_storage_map = {} -> null - template_uuid = "422a010e-6459-05cb-38fb-6360bbda149b" -> null - timeout = 30 -> null - customize { - dns_server_list = [] -> null - dns_suffix_list = [] -> null - timeout = 10 -> null - linux_options { - domain = "example.com" -> null - host_name = "os-lin1" -> null - hw_clock_utc = true -> null } - network_interface {} } } - disk { - attach = false -> null - controller_type = "scsi" -> null - datastore_id = "datastore-3006" -> null - device_address = "scsi:0:0" -> null - disk_mode = "persistent" -> null - disk_sharing = "sharingNone" -> null - eagerly_scrub = false -> null - io_limit = -1 -> null - io_reservation = 0 -> null - io_share_count = 1000 -> null - io_share_level = "normal" -> null - keep_on_remove = false -> null - key = 2000 -> null - label = "os-lin1-disk0" -> null - path = "os-lin1/os-lin1.vmdk" -> null - size = 100 -> null - thin_provisioned = true -> null - unit_number = 0 -> null - uuid = "6000C290-906a-e5c1-2ce5-81c5bf359636" -> null - write_through = false -> null } - network_interface { - adapter_type = "e1000" -> null - bandwidth_limit = -1 -> null - bandwidth_reservation = 0 -> null - bandwidth_share_count = 50 -> null - bandwidth_share_level = "normal" -> null - device_address = "pci:0:7" -> null - key = 4000 -> null - mac_address = "00:50:56:9c:ac:0a" -> null - network_id = "network-3007" -> null - use_static_mac = false -> null } } # module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0] will be destroyed - resource "vsphere_virtual_machine" "windowsvm" { - boot_delay = 0 -> null - boot_retry_delay = 10000 -> null - boot_retry_enabled = false -> null - change_version = "2023-07-29T06:12:22.948276Z" -> null - cpu_hot_add_enabled = false -> null - cpu_hot_remove_enabled = false -> null - cpu_limit = -1 -> null - cpu_performance_counters_enabled = false -> null - cpu_reservation = 0 -> null - cpu_share_count = 2000 -> null - cpu_share_level = "normal" -> null - custom_attributes = {} -> null - datastore_id = "datastore-3006" -> null - default_ip_address = "192.168.1.107" -> null - efi_secure_boot_enabled = false -> null - enable_disk_uuid = false -> null - enable_logging = false -> null - extra_config = {} -> null - extra_config_reboot_required = true -> null - firmware = "bios" -> null - force_power_off = true -> null - guest_id = "windows2019srv_64Guest" -> null - guest_ip_addresses = [ - "192.168.1.107", - "2600:1700:1c00:c230::49", - "2600:1700:1c00:c230:61a0:e4cf:ac1a:e0ac", - "fe80::61a0:e4cf:ac1a:e0ac", ] -> null - hardware_version = 20 -> null - host_system_id = "host-3003" -> null - id = "421c98b8-dbd1-3560-9ead-bd590c9774c6" -> null - ide_controller_count = 2 -> null - latency_sensitivity = "normal" -> null - memory = 2048 -> null - memory_hot_add_enabled = false -> null - memory_limit = -1 -> null - memory_reservation = 0 -> null - memory_share_count = 20480 -> null - memory_share_level = "normal" -> null - migrate_wait_timeout = 30 -> null - moid = "vm-6004" -> null - name = "os-win1" -> null - nested_hv_enabled = false -> null - num_cores_per_socket = 1 -> null - num_cpus = 2 -> null - pci_device_id = [] -> null - power_state = "on" -> null - poweron_timeout = 300 -> null - reboot_required = false -> null - resource_pool_id = "resgroup-10" -> null - run_tools_scripts_after_power_on = true -> null - run_tools_scripts_after_resume = true -> null - run_tools_scripts_before_guest_reboot = false -> null - run_tools_scripts_before_guest_shutdown = true -> null - run_tools_scripts_before_guest_standby = true -> null - sata_controller_count = 0 -> null - scsi_bus_sharing = "noSharing" -> null - scsi_controller_count = 1 -> null - scsi_type = "pvscsi" -> null - shutdown_wait_timeout = 3 -> null - swap_placement_policy = "inherit" -> null - sync_time_with_host = false -> null - sync_time_with_host_periodically = false -> null - tags = [] -> null - tools_upgrade_policy = "manual" -> null - uuid = "421c98b8-dbd1-3560-9ead-bd590c9774c6" -> null - vapp_transport = [] -> null - vbs_enabled = false -> null - vmware_tools_status = "guestToolsRunning" -> null - vmx_path = "os-win1/os-win1.vmx" -> null - vvtd_enabled = false -> null - wait_for_guest_ip_timeout = 0 -> null - wait_for_guest_net_routable = true -> null - wait_for_guest_net_timeout = 5 -> null - clone { - linked_clone = false -> null - ovf_network_map = {} -> null - ovf_storage_map = {} -> null - template_uuid = "421cab5b-5c97-2427-2042-57f3c08b3adc" -> null - timeout = 30 -> null - customize { - dns_server_list = [] -> null - dns_suffix_list = [] -> null - timeout = 10 -> null - network_interface {} - windows_options { - auto_logon = false -> null - auto_logon_count = 1 -> null - computer_name = "os-win1" -> null - full_name = "Administrator" -> null - organization_name = "Managed by Terraform" -> null - run_once_command_list = [] -> null - time_zone = 85 -> null - workgroup = "workgroup" -> null } } } - disk { - attach = false -> null - controller_type = "scsi" -> null - datastore_id = "datastore-3006" -> null - device_address = "scsi:0:0" -> null - disk_mode = "persistent" -> null - disk_sharing = "sharingNone" -> null - eagerly_scrub = false -> null - io_limit = -1 -> null - io_reservation = 0 -> null - io_share_count = 1000 -> null - io_share_level = "normal" -> null - keep_on_remove = false -> null - key = 2000 -> null - label = "os-win1-disk0" -> null - path = "os-win1/os-win1.vmdk" -> null - size = 100 -> null - thin_provisioned = true -> null - unit_number = 0 -> null - uuid = "6000C29a-2cbf-5bbc-3e49-b5995e49f9e2" -> null - write_through = false -> null } - network_interface { - adapter_type = "vmxnet3" -> null - bandwidth_limit = -1 -> null - bandwidth_reservation = 0 -> null - bandwidth_share_count = 50 -> null - bandwidth_share_level = "normal" -> null - device_address = "pci:0:7" -> null - key = 4000 -> null - mac_address = "00:50:56:9c:0f:fe" -> null - network_id = "network-3007" -> null - use_static_mac = false -> null } } Plan: 0 to add, 0 to change, 2 to destroy. module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Destroying... [id=421c98b8-dbd1-3560-9ead-bd590c9774c6] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Destroying... [id=421c12ae-3839-ea18-56ed-e81b2dc0db49] module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Still destroying... [id=421c12ae-3839-ea18-56ed-e81b2dc0db49, 10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Still destroying... [id=421c98b8-dbd1-3560-9ead-bd590c9774c6, 10s elapsed] module.virtual_machine["os-win1"].vsphere_virtual_machine.windowsvm[0]: Destruction complete after 13s module.virtual_machine["os-lin1"].vsphere_virtual_machine.linuxvm[0]: Destruction complete after 13s Destroy complete! Resources: 2 destroyed. |
Useful Articles
Using terraform to clone a virtual machine on VMware vSphere infrastructure
Terraform module clone VMware vSphere Linux and Windows virtual machine
Terraform VMware vSphere Virtual Machine customization clone failed on Windows
Terraform VMware vSphere Virtual Machine cloning Operating system not found
How to Install Minikube on Ubuntu - Step by Step
MINIKUBE Unable to start VM - This computer doesn't have VT-X AMD-v enabled
Install and Setup your own Kubernetes Cluster with K3s
Rancher k3s.yaml permission denied when using kubectl - Kubernetes