Terraform provider for Xen Orchestra
-
What is Terraform?
Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
https://registry.terraform.io/providers/terra-farm/xenorchestra/latest/docsXO compatibility
We immediately saw that would be a good idea to get this for XO. That's why I created an issue in this way, hoping for someone to make it real one day: https://github.com/terra-farm/terraform-provider-xenserver/issues/7
Thanks to Dom Del Nano, you can now use Terraform to talk directly to your central XO instance. This way, you have one entry point to configure everything:
https://terra-farm.github.io/provider-xenorchestra/index.html
https://registry.terraform.io/providers/terra-farm/xenorchestra/latest/docs
Note: more documentation will come soon.
Legacy: XCP-ng plugin
Before that, a XenServer/XCP-ng plugin already existed, but the drawback was the need to connect a specific pool master to do your operation, losing the main advantage of this kind of platform: simplicity with always one entry point.
-
Hi @olivierlambert - how do I install the plugin...could not find a repo to compile with go
https://www.terraform.io/docs/providers/type/community-index.html
-
Plugin is here: https://github.com/terra-farm/terraform-provider-xenorchestra
However, I'm not a terraform expert, you should ask here: https://github.com/terra-farm/terraform-provider-xenorchestra/issues
-
I have compiled the plugin on xcp-ng 8 but it don't work at all it ask for a old api plugin
-
@olivierlambert I'm guessing this project is not really well supported.
Is Terraform the only way to get automated VM provisioning with xcp-ng?
-
@Biggen feel free to fork or ask repo permissions to contribute then
You can have automated provisioning multiple ways, can you describe your use case exactly?
-
Honestly no real world use case at this time. Just want to begin learning to automate some more of a my tasks. I wasn't sure what the correct way is to automate provisioning with xcp-ng. In other words, what tools I need to use.
-
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...?
-
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 + XO + cloud-init + terraform + ansible
-
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
-
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. -
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:
or even better, the original article:
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.
-
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.