mtcoffee / xcp-ng-terraform-examples

A few examples of using Terraform to automate server builds on XCP-NG. Also see my other repo, xcp-ng-packer-examples which you may want to start with.
0 stars 1 forks source link

Question about multiple VM creation #1

Open jothoma1 opened 3 weeks ago

jothoma1 commented 3 weeks ago

Thanks again for your example, save me a lot of time ! Just wanted to know if you have an example with multiple VM creation with terraform ?

I want to create 20 Windows RDS and dont really know how to do this with XCP-NG Thanks !

mtcoffee commented 3 weeks ago

You will want to refactor it to use dhcp and then you could use the Terraform count feature. https://spacelift.io/blog/terraform-count-for-each

A rough example would be something like this:

resource "xenorchestra_vm" "vm" {
  count = 3

  name_label     = "windows-server-${count.index}"
  template_name  = "Windows Server 2019 Template"

  network {
    network_id = "Pool-wide network associated with eth0"
  }
  ...
jothoma1 commented 3 weeks ago

Thanks @mtcoffee will try the count feature but i think i will have to use it with 2 arrays since i cant use DHCP :( only static IP