XO and terraform
-
hi guys
im rather new to XCP and Terraform.
I am an adult student in system and network engineering (last year) and for my project i have chosen to deploy VMs with terraform. configuring with most likely ansible.
So far i am able to deploy a VM however at first run of my ''playbook'' it creates the VM and no disk is being created. second run the disk is created and attached but in a diconnected state.
then i need to shut down the VM in XO and run my terraform template once again, the VM is being powered on and the disk is connected.
im not sure what causes this behaviour.
here is my current template.
here is my current template.
terraform { required_providers { xenorchestra = { source = "terra-farm/xenorchestra" version = "~> 0.26.0" } } } provider "xenorchestra" { url = "wss://"my_xo_ip" username = "myusername" password = "Mypassword" insecure = true } # Fetch the template data "xenorchestra_template" "vm_template" { name_label = "Terraform_Template_Win_Core" } # Fetch the network data "xenorchestra_network" "network" { name_label = "eth0" } # Fetch the storage repository data "xenorchestra_sr" "sr" { name_label = "Local storage" } # Create the VM with explicit dependency on the storage repository resource "xenorchestra_vm" "vm1" { name_label = "terraform_VM" template = data.xenorchestra_template.vm_template.id cpus = 2 memory_max = 4294967296 # Network configuration network { network_id = data.xenorchestra_network.network.id } # Disk configuration with explicit dependency on storage repository disk { sr_id = data.xenorchestra_sr.sr.id size = 10737418240 name_label = "VM root volume" } # CD-ROM configuration cdrom { id = "09ab237e-9a35-4d88-b787-24c1b6fa7779" } # Automatically power on the VM power_state = "Running" # Ensure the VM depends on the successful creation of the storage repository depends_on = [data.xenorchestra_sr.sr] }
its also suboptimal as i then would need to run the windows ISO from the XO console..
any tips would be greatly appreciated.