<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Guest OS customization using Terraform - fail on first boot in vSphere Management SDK Discussions</title>
    <link>https://communities.vmware.com/t5/vSphere-Management-SDK/Guest-OS-customization-using-Terraform-fail-on-first-boot/m-p/2947602#M14742</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Terraform to deploy a vm exported from AWS.&lt;/P&gt;&lt;P&gt;The process is the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;- I use Packer to build an AMI in AWS&lt;/P&gt;&lt;P&gt;- The ami is then exported in vmdk format to VMware using terraform ( using a clone from an s3 bucket into a datastore )&amp;nbsp;&lt;/P&gt;&lt;P&gt;- a template was previously created and using terraform the template is used to create a vm, the template does not have disks attached, the disk are attached when the vm is created.&lt;/P&gt;&lt;P&gt;When the vm is started it fails with the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Customization of the guest operating system is not supported due to the given reason: Tools is not installed in the GuestOS. Please install the latest version of open-vm-tools or VMware Tools to enable GuestCustomization.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If I delete the VM (not remove the disk, using the &lt;EM&gt;Remove from inventory&lt;/EM&gt; command) and rerun the terraform apply command it boot the vm and it is able to customize without any problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;resource "vsphere_virtual_machine" "vm" {
  name             = "test_machine_vm_01"
  resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
  datastore_id     = data.vsphere_datastore.datastore.id
  folder           = "test"
  num_cpus         = data.vsphere_virtual_machine.template.num_cpus
  memory           = data.vsphere_virtual_machine.template.memory
  guest_id         = "rhel7_64Guest"
  scsi_type                               = data.vsphere_virtual_machine.template.scsi_type
  tools_upgrade_policy                    = "upgradeAtPowerCycle"
  run_tools_scripts_after_power_on        = true
  run_tools_scripts_after_resume          = true
  run_tools_scripts_before_guest_shutdown = true
  run_tools_scripts_before_guest_standby  = true
  network_interface {
    network_id   = data.vsphere_network.network.id
    adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]
  }
  disk {
    attach       = true
    path         = var.VMDK_PATH_DISK_1
    label        = "disk.0"
    datastore_id = data.vsphere_datastore.datastore.id
  }
  disk {
    attach       = true
    path         = var.VMDK_PATH_DISK_2
    label        = "disk.1"
    datastore_id = data.vsphere_datastore.datastore.id
    unit_number  = 1
  }
  clone {
    template_uuid = data.vsphere_virtual_machine.template.id
    customize {
      linux_options {
        host_name = "rhel7-image"
        domain    = "mipa.med.ds.osd.mil"
      }
      network_interface {
        ipv4_address = "myip"
        ipv4_netmask = 24
      }
      ipv4_gateway = "mygateway"
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my image created with packer I use the following commands as root before shutting it down&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;systemctl enable vmtoolsd
systemctl start vmtoolsd
systemctl status vmtoolsd&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thank you !&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jan 2023 15:44:48 GMT</pubDate>
    <dc:creator>danilo-patrucco</dc:creator>
    <dc:date>2023-01-09T15:44:48Z</dc:date>
    <item>
      <title>Guest OS customization using Terraform - fail on first boot</title>
      <link>https://communities.vmware.com/t5/vSphere-Management-SDK/Guest-OS-customization-using-Terraform-fail-on-first-boot/m-p/2947602#M14742</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Terraform to deploy a vm exported from AWS.&lt;/P&gt;&lt;P&gt;The process is the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;- I use Packer to build an AMI in AWS&lt;/P&gt;&lt;P&gt;- The ami is then exported in vmdk format to VMware using terraform ( using a clone from an s3 bucket into a datastore )&amp;nbsp;&lt;/P&gt;&lt;P&gt;- a template was previously created and using terraform the template is used to create a vm, the template does not have disks attached, the disk are attached when the vm is created.&lt;/P&gt;&lt;P&gt;When the vm is started it fails with the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Customization of the guest operating system is not supported due to the given reason: Tools is not installed in the GuestOS. Please install the latest version of open-vm-tools or VMware Tools to enable GuestCustomization.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If I delete the VM (not remove the disk, using the &lt;EM&gt;Remove from inventory&lt;/EM&gt; command) and rerun the terraform apply command it boot the vm and it is able to customize without any problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;resource "vsphere_virtual_machine" "vm" {
  name             = "test_machine_vm_01"
  resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
  datastore_id     = data.vsphere_datastore.datastore.id
  folder           = "test"
  num_cpus         = data.vsphere_virtual_machine.template.num_cpus
  memory           = data.vsphere_virtual_machine.template.memory
  guest_id         = "rhel7_64Guest"
  scsi_type                               = data.vsphere_virtual_machine.template.scsi_type
  tools_upgrade_policy                    = "upgradeAtPowerCycle"
  run_tools_scripts_after_power_on        = true
  run_tools_scripts_after_resume          = true
  run_tools_scripts_before_guest_shutdown = true
  run_tools_scripts_before_guest_standby  = true
  network_interface {
    network_id   = data.vsphere_network.network.id
    adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]
  }
  disk {
    attach       = true
    path         = var.VMDK_PATH_DISK_1
    label        = "disk.0"
    datastore_id = data.vsphere_datastore.datastore.id
  }
  disk {
    attach       = true
    path         = var.VMDK_PATH_DISK_2
    label        = "disk.1"
    datastore_id = data.vsphere_datastore.datastore.id
    unit_number  = 1
  }
  clone {
    template_uuid = data.vsphere_virtual_machine.template.id
    customize {
      linux_options {
        host_name = "rhel7-image"
        domain    = "mipa.med.ds.osd.mil"
      }
      network_interface {
        ipv4_address = "myip"
        ipv4_netmask = 24
      }
      ipv4_gateway = "mygateway"
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my image created with packer I use the following commands as root before shutting it down&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;systemctl enable vmtoolsd
systemctl start vmtoolsd
systemctl status vmtoolsd&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thank you !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 15:44:48 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Management-SDK/Guest-OS-customization-using-Terraform-fail-on-first-boot/m-p/2947602#M14742</guid>
      <dc:creator>danilo-patrucco</dc:creator>
      <dc:date>2023-01-09T15:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Guest OS customization using Terraform - fail on first boot</title>
      <link>https://communities.vmware.com/t5/vSphere-Management-SDK/Guest-OS-customization-using-Terraform-fail-on-first-boot/m-p/2961367#M14773</link>
      <description>&lt;P&gt;If anyone lands on this, The problem is that the machine is built in AWS, and vmtoolsd does not start at all when outside of VMware environment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution is to build a packer image with the packer VMware library, or manually start the vm for the first time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 14:49:24 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Management-SDK/Guest-OS-customization-using-Terraform-fail-on-first-boot/m-p/2961367#M14773</guid>
      <dc:creator>danilo-patrucco</dc:creator>
      <dc:date>2023-03-28T14:49:24Z</dc:date>
    </item>
  </channel>
</rss>

