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

user_data for Windows VM #84

Closed
pdahake opened this issue Oct 24, 2019 · 1 comment
Closed

user_data for Windows VM #84

pdahake opened this issue Oct 24, 2019 · 1 comment

Comments

@pdahake
Copy link

pdahake commented Oct 24, 2019

Is your feature request related to a problem? Please describe.
We want to create Windows VMs for Nutanix. As part of the provisioning the VM, we would want to execute user data (powershell scripts). Right now, the porvider supports cloud_init for Linux VMs. We want something for the windows platform.

Describe the solution you'd like
User data like you have for AWS EC2s would be helpful.

Describe alternatives you've considered
Without the user data, we have to execute scripts after the VM is provisioned.

@coderGo93
Copy link
Contributor

coderGo93 commented Jun 8, 2020

Hello @pdahake , I think it already exists now with guest_customization_sysprep , is that what you meant, isn't it? if so, here an example of sysprep/unattend.xml using PREPARED

locals {
  vmname_prefix = "test-vm"
  amount        = 1
  image_name    = "windows_2016"
  cluster_name = "cluster"
  vm_username = "administrator"
}
variable "vm_password" {
  default = "test"
}
data "nutanix_image" "centos" {
  image_name = local.image_name
}
data "nutanix_subnet" "subnet" {
  subnet_name = "Rx-Automation-Network"
}
data "nutanix_cluster" "cluster_by_name" {
  name = local.cluster_name
}
data "template_file" "unattend" {
  template = "${file("unattend.xml")}"
  vars = {
    vmname_prefix = local.vmname_prefix
    index         = 1
    vm_password   = var.vm_password
  }
}

resource "nutanix_virtual_machine" "vm" {
  name                 = "${local.vmname_prefix}-1"
  cluster_uuid         = data.nutanix_cluster.cluster_by_name.id
  num_vcpus_per_socket = "1"
  num_sockets          = "2"
  memory_size_mib      = 2048
  nic_list {
    subnet_uuid = data.nutanix_subnet.subnet.id
  }
  guest_customization_sysprep = {
    install_type = "PREPARED"
    unattend_xml = base64encode(data.template_file.unattend.rendered)
  }
  disk_list {
    data_source_reference = {
      kind = "image"
      uuid = data.nutanix_image.centos.id
    }
  }

@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