Terraform provider for Xen Orchestra


  • XCP-ng Team

    Using XO API is the best way 🙂 (via xo CLI for example). We also have some recipes that we built inside XOA, we can probably show you how to use them if you want to leverage Cloudinit with templates!



  • @olivierlambert So using the XO API would negate the need for Terraform? I guess I don't understand where the XO API commands would be put.

    How do I install the XO API? Can this installed on any VM (or host) so long as it has access to the XO host/VM?

    Edit: So I got xo-cli installed and it is talking with my XO. Is there any in depth documentation on xo-cli? Like creating a VM with it and assigning CPUs, Memory, SR, etc...?


  • XCP-ng Team

    I'm not telling that. I would say that Terraform capability is good because people/ops without any XCP knowledge can use it (I mean, people already used to Terraform). I think you can ask for repo access so you'll be able to continue/improve the project 🙂

    Terraform is just a way to make "infrastructure as code", there's plenty. xo-cli + your scripts is one of it. Or using the API directly. It's less standard, so that's why Terraform is a good idea.



  • Hi @Biggen, Hi @olivierlambert ,

    I am also in the process of evaluating a terraform+ansible based tool-stack.

    • XCP-ng + XO + cloud-init + terraform + ansible
      vs.
    • ESXi + vServer + cloud-init + terraform + ansible

    After a lot of pain and constant cursing of the cloud-init documentation I am finally at a point where I can deploy a ubuntu-1804 machine from a template and have it come up with the network settings what I want it to have. (i.e. a static config that, in a later step, will be created from data out of an IPAM / inventory system)

    This is step one if I want to be able to control the deployment of new machines and not have them shop around for the first dhcp response they get...

    However this seems to only work if I use the NoCloud data source.
    Currently I am somewhat stuck.
    I can't seem to get terraform to provide network-configuration settings to the VM.

    Apparently cloud-init was designed with just the public cloud in mind. Thus they seem to try to keep those pesky users away from the precious network configuration.

    On the other hand, What would be the best way to implement a terraform-driven infrastructure, if I can't configure the host's IP settings directly via cloud-init? Which data source would you suggest for a private cloud?

    I'd much rather implement it all based on XCP-ng+XO but ESXi+vSphere seems to have a headstart where it comes to integration with both terraform and cloud-init.

    What I am currently missing in XCP-ng/XO is a vision for the private cloud in times of infrastructure as code and DevOps. A world where Devs do have more power (though not necessarily more skills) to spin up virtual environments just to run their test suite.

    I'd also love to see some kind of "This is how we imagine things to scale..." Like the very readable Cloud Architecture documentation of OpenNebula.


  • XCP-ng Team

    Network config should work, it's very likely a configuration issue in your VM.

    @fohdeesha might be able to assist on that. Obviously, if you can open a support ticket, it will be easier for us 🙂


  • XCP-ng Team

    it's hard to understand exactly what you're asking, but that only works with the nocloud datasource because that's the design of cloud-init (out of our control). nocloud is the only data source (versus openstack) that cloud-init will allow network config: https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html



  • @olivierlambert I managed to set the "User config" stuff by terraform. What I can't seem to get my head around is how to set the "Network config" for the nocloud provider via terraform. Are there examples tf files that I could take as a starting off point?

    @fohdeesha So if nocloud is the only datasource that does allow to configure the newly created VM's network, how is the network configured in all the other cases? For the terraform vshere provider I can see it done via "customize { network_interface { ipv4_address ".
    How do they get that information to the inside of the machine? Do they use the guest-tools to manipulate the interface settings? And how should this work on XCP-ng? I was under the impression that the guest tools were only reporting the network settings from the guest to the host.

    What I want to do with terraform and cloud-init, is to create a private network with multiple VMs where I can reliably connect from one machine to another by their IP.
    If I can't configure the IP settings with terraform via cloud-init, but assuming that I can set the MAC addresses via terraform, I guess I will have to go with a DHCP server with static mapping of MAC to IP there.


  • XCP-ng Team

    In terraform for vsphere they are not using cloud-init, they're using "guest customization" which apparently just uses vmware guest tools: https://docs.vmware.com/en/VMware-vSphere/6.5/com.vmware.vsphere.vm_admin.doc/GUID-E63B6FAA-8D35-428D-B40C-744769845906.html#GUID-E63B6FAA-8D35-428D-B40C-744769845906

    XCP-NG / xen guest tools do not have the option of configuring the network like this that I know of, only reporting



  • XCP-NG / xen guest tools support network configuration through guest agent but for Windows guests only:

    https://www.citrix.com/community/citrix-developer/citrix-hypervisor-developer/citrix-hypervisor-developing-products/citrix-hypervisor-staticip.html

    or even better, the original article:

    https://web.archive.org/web/20180218110151/https://xenserver.org/blog/entry/set-windows-guest-vm-static-ip-address-in-xenserver.html

    Using the same mechanism (XAPI->xenstore), an agent for *nix guest can be implemented too. Unfortunately, no one has stepped in for that job. Citrix seems to be uninterested. I have a basic idea how to implement the agent but I lack free time to do so.


  • XCP-ng Team

    This is what we use (xenstore) for XOA deploy. However, Cloudinit is almost a de facto standard, so we think it's better to use it than custom scripts.


Log in to reply
 

XCP-ng Pro Support

XCP-ng Pro Support