Giter Club home page Giter Club logo

Comments (6)

johng521888 avatar johng521888 commented on August 27, 2024 1

Hey @johng521888 I tried this myself, I added both a simple disk block and one with a path to an existing vmdk. Neither of these destroy the VM, they just reconfigure it. I ran this experiment on a basic VM and on one that I created from a template.

Can you try updating your provider to the latest version? If you continue to encounter this problem please share your configuration and the output from terraform plan so that we can see the diff

Hi spacegospod,
i have tried today. but have same issue in version 2.8.2 vsphere provider. i have two modules as below
1、vshereVM(to create a machine)
resource "vsphere_virtual_machine" "vm" {
name=var.hostname
num_cpus = var.vcpu
memory = var.memory
datastore_id = xxx
resource_pool_id = xxx
guest_id = xxx
scsi_type = xxx

disk {
    lable = "disk0"
    size = var.disk_size
    eagerly_scrub = xxx
    thin_provisioned = xxx
}
#disk {
    #attach = true
    #path = "xxxx/thisistestdisk.vmdk"
    #label = "disk1"
    #datastore_id = xxx
    #unit_number = 1
    #io_limit = 3000 

#}
......
......
}
first time i create this machine with one disk use terraform apply

2、create another disk use below tf
resource "vsphere_virtual_disk" "virtual_disk" {
size = 100
vmdk_path = first_create_machine_UUID/thisistestdisk.vmdk
datacenter = same_machine_datacenter
datasotore = same_machine_datastore
}

3、Uncomment virtual machine second disk in main.tf and execute terraform apply in virtual machine module

resource "vsphere_virtual_machine" "vm" {
name=var.hostname
num_cpus = var.vcpu
memory = var.memory
datastore_id = xxx
resource_pool_id = xxx
guest_id = xxx
scsi_type = xxx

disk {
    lable = "disk0"
    size = var.disk_size
    eagerly_scrub = xxx
    thin_provisioned = xxx
}
disk {
    attach = true
    path = first_create_machine_UUID/thisistestdisk.vmdk
    label = "disk1"
    datastore_id = xxx
    unit_number = 1
    io_limit = 3000 

}
......
......
}

plan:1 to add, 0 to change, 1 to destroy.

I don't know why this happens, can I avoid destroying my virtual machine? Because not everyone knows at the beginning whether they want to add a second disk

from terraform-provider-vsphere.

github-actions avatar github-actions commented on August 27, 2024

Hello, johng521888! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

from terraform-provider-vsphere.

spacegospod avatar spacegospod commented on August 27, 2024

Hey @johng521888 I tried this myself, I added both a simple disk block and one with a path to an existing vmdk.
Neither of these destroy the VM, they just reconfigure it.
I ran this experiment on a basic VM and on one that I created from a template.

Can you try updating your provider to the latest version?
If you continue to encounter this problem please share your configuration and the output from terraform plan so that we can see the diff

from terraform-provider-vsphere.

spacegospod avatar spacegospod commented on August 27, 2024

Adding a disk shouldn't just by itself be able to force a VM to get re-created.
Have any changes been made to this VM outside of Terraform?

I'd be curious to see the output just above 1 to add, 0 to change, 1 to destroy.
Terraform should display the configuration diff.
It would also be useful to run the provider with TF_LOG set to TRACE and share the detailed logs, just make sure to obfuscate any potentially sensitive data.

from terraform-provider-vsphere.

johng521888 avatar johng521888 commented on August 27, 2024

Thank you @spacegospod.
i have solved this problem. the reason is that the instance lifycycle has not been completed. so each apply operation will also recreate the vm.

My VM network name contains special symbols, and terraform cannot recognize this symbol "/", which causes the life cycle of the created VM to fail to complete normally.

from terraform-provider-vsphere.

spacegospod avatar spacegospod commented on August 27, 2024

Thank you for the update, I'm going to close the ticket now.
Feel free to re-open if you need assistance

from terraform-provider-vsphere.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.