-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Needs clarification on the use of vsphere_virtual_disk #150
Comments
Hey @javefang - this is a great solution to this problem! 👍 I currently have on my roadmap plans to revisit the Hence, I want to hold off on any serious refactors of the resource until this work is properly scoped out as to avoid duplicating too much effort on a resource that could look significantly different after the work is complete. The great part about this, however, is that by handing this responsibility off to another resource, we don't have to worry about pending refactors. 😄 I don't necessarily have this on my roadmap right now, but would gladly look over a PR and merge it if it were to come in! Some comments I have on the PoC laid out:
Consider whether or not we should be making the disk independent by default or not - to ensure that it's excluded from snapshots. This is especially important for larger disks, and considering that, I would prefer that the default was independent. Consider what is necessary to ensure that a VM does not delete the disk when the VM is deleted. It looks like you have a good consideration as to this workflow already. Actually, this workflow should be pretty natural, because tainting a VM resource should propagate down the graph, stopping at the attachment resource, meaning that the attachment resource will destroy itself before the VM destroys itself, ensuring that the disk is safely detached before the VM is deleted, which should be adequate to protect it from deletion. Finally, I want to get into the habit of referencing VMs by their unique identifiers - either by MOID or UUID. The latter is what I think we are leaning on as this is what I've asked to have happen in #107. Again, I'm not too sure when I'm personally going to be able to look into this, however I think this is a great step to making the state of the resource saner in general. If anyone takes this on and puts in a PR, please reference this issue! |
That's very helpful thank you! I will try to pick up when I have a chance. |
This is very much how the OpenStack provider works with "Creating" and attaching floating IPs to instances. I think it makes a lot of sense to follow the same pattern as established in other providers. Also, I think this model could be applied to interfaces, disks, and any additional "VM components". Anyway, just wanted to throw my $0.02 in that @javefang resource seems elegant and would solve a lot of problems we've run into as far as wanting to customize a "base" or "minimal" template. |
I am using terraform in a similar fashion in a development environment. I am having the same problems. I would add that there needs to be some means to handle raw device maps in the vsphere_virtual_disk resource. I also have issue with terraform refresh thinking it needs to reroll vms when a disk has been storage vmotioned from another location. |
Would be a nice one to have. |
The documentation is lacking for "attached disks." I tried to start editing the docs, but digging around the docs and linking off to other repos, only to find several PRs pending for docs, I felt it better to share the solution here. Note: There has been some additional work done in this area. And there now is an Note: my code below was created as a composable module, to where I Disk Attach RequirementsIf defining a
... then there a few undocumented requirements that are needed. I ran into these after Running The additional requirements are:
Afterwards, it's up to your Provisioning scripts to mount the disk, format it, etc. Hopefully the docs get updated to help the next person along. |
@eduncan911 does this process allow you to resize the disk? |
If you are asking if IMO, staying true to Terraform's descriptive nature, I'd say it should not. It should mark the resource as dirty and provision a new, larger/smaller disk. But that's just my opinion. The vSphere Provider developers here may allow resizing. It's up to them and their code. I'd say just try it. Provision a disk at 1 GB, change it to 2 GB, and |
@eduncan911 agree that the disk size piece needs to be better documented. Not sure I agree with the inability to resize disks - lots of resources allow modification vs just build a new. But I'll def give it a shot. Thanks for documenting your work! :) |
Does the issue still Open I am working with vSphere 6.7 where export give 2 files ( ovf and vmdk) and I want to create VM using ovf and vmdk. didn't find the way, can you please suggest the alternate for creating VM with ovf and vmdk file |
After testing, resizing a vsphere_virtual_disk resource always seems to delete the disk.
|
It looks like we have the original request in this issue covered. #851 is open for dealing with the resizing issue. I'm going to close this one and we'll track it there. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Hi there,
We are doing immutable infrastructure here with Terraform and VSphere. This means we are creating and destroying virtual machines a lot. During which we have a use-case which hopefully is very common to others as well.
For example, when we deploy a cluster of ETCD nodes. For each node we want to create a vsphere_virtual_machine and a separate vsphere_virtual_disk for storing persistent data. During an update, ideally we can keep the disk, recreate the VM and re-attach the data disk to the new VM. However, it is not very clear on if this is possible or how this should be done.
e.g. On the AWS provider, we can do this by creating an "aws_volume_attachment" to attach a given aws_ebs_volume to an aws_instance. On the VSphere provider I can't seem to find an equivalent.
Terraform Version
v0.10.2
Affected Resource(s)
Please list the resources as a list, for example:
What have I tried so far?
Initially we though we can just create a vsphere_virtual_disk at specific VMDK path, and create a "disk" section to reference the VMDK path when creating the vsphere_virtual_machine. (See configs below)
This approach has several problems:
We then tried to create the data disk directly in the vsphere_virtual_machine section, and set the "keep_on_remove" option, hoping the disk can be kept and re-attached when the machine is recreated.
When the VM is destroyed. The folder which contains VM files will remain, and only contains the data disk file (etcd_data.vmdk). Everything works correctly until now. However, when the VM is recreated with the same name. Instead of creating all the new VM files in the existing folder (etcd-0), except for the data disk file, a new folder is created (etcd-0-1), and a new data disk file is created and attached to the new VM...
It looks like we cannot use vsphere_virtual_disk to create persistent data disk for the VM. I wonder how others are using this resource?
How I think the problem could be resolved?
I feel like we should have a new resource "vsphere_virtual_disk_attachment", which use govmomi's api (see example of the kuberentes vsphere provider code) to control the attachment and detachment of disks created by vsphere_virtual_disk.
Example usage should be like
And the behaviour will be
Create
(if cloud-init is used, it must wait for the disk to attach before attempting to format and mount it)
Update (recreate the VM)
Destroy
I'm happy to contribute if someone could confirm if this is a genuine issue and if the proposal above makes sense?
Thanks
Xinghong
The text was updated successfully, but these errors were encountered: