terra-farm / terraform-provider-xenserver

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

VM creation issue after 7.2 update #17

Closed ajagnanan closed 6 years ago

ajagnanan commented 6 years ago

I encountered another issue after the update. Creating a xenserver_vm doesn't create a VM now, but a template. I'm not sure if additional options are required now, I attached my log output:

* xenserver_vm.utility: template VBD ed74dc4e-0ae1-02fc-ac9b-5056abe6da6c is not referenced
2017/12/05 15:10:20 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* xenserver_vm.utility: template VBD ed74dc4e-0ae1-02fc-ac9b-5056abe6da6c is not referenced

2017/12/05 15:10:20 [DEBUG] plugin: waiting for all plugin processes to complete...
Error: Error applying plan:

1 error(s) occurred:

* xenserver_vm.utility: 1 error(s) occurred:

* xenserver_vm.utility: template VBD ed74dc4e-0ae1-02fc-ac9b-5056abe6da6c is not referenced

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
mborodin commented 6 years ago

@ajagnanan you need to specify dummy VBDs, that correspond to yous template VBD. This was made to fix a bug, when terraform tried to destroy VBD from template because it was not specified in tf-file. Example:

resource "xenserver_vm" "test" {
  base_template_name = "CentOS 7.4 Template"
  name_label = "test"
  static_mem_min = 8589934592
  static_mem_max = 8589934592
  dynamic_mem_min = 8589934592
  dynamic_mem_max = 8589934592
  vcpus = 1
  boot_order = "c"

  hard_drive {
    is_from_template = true
    user_device = "0"
  } # Template VM HDD
  cdrom {
    is_from_template = true
    user_device = "3"
  }
  network_interface {
    network_uuid = "92467b56-21a7-dfdd-b412-978181a69f32"
    device = 0
    mtu = 1500
    mac = ""
    other_config {
        ethtool-gso = "off"
        ethtool-ufo = "off"
        ethtool-tso = "off"
        ethtool-sg = "off"
        ethtool-tx = "off"
        ethtool-rx = "off"
    }
  }
}
ajagnanan commented 6 years ago

Thanks! Awesome that worked, I had to specify the hard_drive and cdrom configs.