terra-farm / terraform-provider-xenserver

XenServer provider for Terraform
https://terra-farm.github.io/provider-xenserver/
MIT License
73 stars 36 forks source link

How to set IP address of new VM? #22

Closed briantopping closed 6 years ago

briantopping commented 6 years ago

As a POC (and potential platform) for terraform-provider-xenserver, I forked @quixoten's terraform_salted_aws and modified it to potentially work with the provider. Initial commit is at https://github.com/briantopping/terraform_salted_aws/commit/f66edf020f420dc78f1dc5647286c7e8e7009679.

In the common AWS provision, the management API provides the ability to recover the IP for an instance, but that's not a part of XenAPI. We do get the GUID back from the provider, but how can that be used to set an IP address so we can do things with the VM? Is there a trick to attach a provisioner to the console through the GUID? It would be a useful part of the example on this project.

Please consider the work I did on terraform_salted_aws as community work toward a more powerful example that we can hopefully merge upstream after it's working. Thanks for everything!

briantopping commented 6 years ago

Hmm, is it possible that Provisioner Connection could be implementedusing the ConsoleClass? It seems like that would be the correct implementation to get into the VM resource that was created and use existing provisioners, no?

EDIT: Looks like that's not exactly the case either. ConsoleClass just provides the API, and that would return the URL for the VNC connection to console (ie. http://xapi-project.github.io/xen-api/consoles.html).

mborodin commented 6 years ago

Hi, I'm currently working on #13 to obtain IP address of a running instance, so if you have for instance DHCP on your network you will be able to use it during provision. There is a way to set static IP to a Windows VM using XenAPI (https://xenserver.org/blog/entry/set-windows-guest-vm-static-ip-address-in-xenserver.html), so if it also works for Linux it will be easy to add that feature to provider, but it needs to be tested for which I currently don't have time.

briantopping commented 6 years ago

Ah indeed. Apologize that I didn't see this earlier. After further review of what I was envisioning, I believe now that VNC/RFB can't provide for a simple stream of text like an SSH, it only provides the rendered framebuffer from the console. What I believe now would be necessary for my concept would be to boot the VM with serial console and provide a provisioner connection through that and may start working on that in parallel to your efforts. http://www.francescoprovino.com/2017/04/16/full-disk-encryption-unlocking-from-virtual-serial-tty-paranoia-xenserver-and-libvirt/ is a similar issue.

I would be happy to test your code when it is ready! I will close this issue since it's basically a duplicate.