Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use an unattend.xml file? #95

Closed
RyanD0001 opened this issue Feb 26, 2020 · 3 comments
Closed

How do I use an unattend.xml file? #95

RyanD0001 opened this issue Feb 26, 2020 · 3 comments

Comments

@RyanD0001
Copy link

RyanD0001 commented Feb 26, 2020

Hi,

when I try to use guest_customization_sysprep in my tf file i get

**'Error: Incorrect attribute value type

on Main-test.tf line 15, in resource "nutanix_virtual_machine" "TF-win19":
15: guest_customization_sysprep = "${base64encode(file("unattend.xml"))}"

Inappropriate value for attribute "guest_customization_sysprep": map of string
required.'**

What am I doing wrong?

this is my tf file:

resource "nutanix_virtual_machine" "TF-win19" {

cluster_uuid = "00053994-c593-946e-6219-246e961bb700"
name = "tf-testwin"
description = "created with terraform"
num_vcpus_per_socket = 1
num_sockets = 1
memory_size_mib = 4096
guest_customization_sysprep = "${base64encode(file("unattend.xml"))}"

nic_list {
# subnet_reference is saying, which VLAN/network do you want to attach here?
subnet_uuid = "740da7c1-7278-403d-b362-b5204cd55d3a"
}

disk_list {

data_source_reference = {
kind = "image"
uuid = "07c25fe9-2f3a-4ed3-97e7-b0d1268bc3ab"
}

}

Thanks,

Ryan

@vCarbs
Copy link

vCarbs commented Mar 6, 2020

Try adding this data block above the resource.

data "template_file" "init" {
  template = "${file("unattend.xml")}"
}

Then set the guest_customization_sysprep value to the below.

guest_customization_sysprep = {
          unattend_xml = "${base64encode("${element(data.template_file.init.*.rendered, count.index)}")}"

@RyanD0001
Copy link
Author

Hi,

Do you have a fully working example that you can share?

Thanks,

Ryan

@vCarbs
Copy link

vCarbs commented Mar 9, 2020

##################################################################################
# PROVIDERS
##################################################################################

provider "nutanix" {
  username     = "admin"
  password     = "mypassword"
  endpoint     = "10.1.1.1"
  insecure     = true
  port         = 9440
  wait_timeout = 10
}

##################################################################################
# DATA
##################################################################################

data "template_file" "cloud" {
  count    = 1
  template = "${file("sysprep.xml")}"
}

##################################################################################
# RESOURCES
##################################################################################

resource "nutanix_virtual_machine" "vm" {
  count                = 1
  name                 = "terraform_win"
  cluster_uuid         = "00053994-c593-946e-6219-246e961bb700"
  num_vcpus_per_socket = 2
  num_sockets          = 1
  memory_size_mib      = 4096
  nic_list {
    subnet_uuid = "740da7c1-7278-403d-b362-b5204cd55d3a"
  }
  disk_list {
    data_source_reference = {
      kind = "image"
      uuid = "07c25fe9-2f3a-4ed3-97e7-b0d1268bc3ab"
    }
  }
  disk_list {
    device_properties {
      disk_address = {
        device_index = 1
        adapter_type = "SCSI"
      }
      device_type = "DISK"
    }
    disk_size_mib = 40960
  }
  guest_customization_sysprep = {
    unattend_xml = "${base64encode("${element(data.template_file.cloud.*.rendered, count.index)}")}"
  }
}

@PacoDw PacoDw closed this as completed Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants