资源定义中的可选部分

时间:2019-07-26 06:48:03

标签: terraform vmware

我想创建Terraform模块,以便在VMware中创建虚拟机,我必须使用模板:

  • 对于Windows VM
  • 对于Linux VM

定义基本相同,但是某些自定义因模板而异。是否可以在资源的同一定义中定义两个不兼容的部分,但是必须根据特定条件使用它们?

customize {

  timeout = 40


  windows_options {

    count = "${var.os_type == "windows" ? 1 : 0 }"


    computer_name     = "${lower(var.envname)}${var.vm_name}"
    organization_name = "Org"

    join_domain           = "${var.domain}"

    domain_admin_user     = "${var.domain_user}"
    domain_admin_password = "${var.domain_password}"

    admin_password = "${var.admin_password}"
    auto_logon     = "true"

    run_once_command_list = "${var.run_once}"

  }


  linux_options {

    count = "${var.os_type == "windows" ? 0 : 1 }"


    host_name = "${lower(var.envname)}${var.vm_name}"
    domain    = "${var.domain}"

  }
}

  

vsphere_virtual_machine.vm:“克隆.0.customize.0.windows_options”:   与clone.0.customize.0.linux_options冲突

Terraform v0.11.14

0 个答案:

没有答案