Format of cloudinit user-data variable in vsphere-clone

Hello,

I was following the documentation here vSphere Clone - Builders | Packer | HashiCorp Developer, but I’m not sure what what the user-data variable should look like:

   vapp {
     properties = {
        hostname  = var.hostname
        user-data = base64encode(var.user_data)
     }
   }

I’m guessing I cannot simply give the path to a yaml file, right?
Until now I’ve used packer with vsphere-iso and with the http service that provides the files during boot time.

What I did was to create a variable like this:

variable "user_data" {
  type = string
  default = "#cloud-config\nusers:\n  - default\n  - name: packer\n    groups: sudo\n    sudo: ['ALL=(ALL) NOPASSWD:ALL']\n    shell: /bin/bash\n    passwd: $6$qvwretGajI9$p91l4liy7HBIbpNGju0MjdmgBjrRe/8S42zaJpYPn.nIbPXagSGYnkoa/BO9Za7O6gQQuMeKBmLCVtb6pDrzc/"
}

Which sets the user to ‘packer’ and the password to ‘packer’.
Unfortunately this still isn’t working, even if I’m encoding it to base64. Might be an issue related more to vsphere and ubuntu’s cloud image. I’m not sure yet.

Ok, so the issue was that cloud-init actually locks password login by default, while it doesn’t disable the user’s account.
lock-passwd: false solves this. But the solution to it was actually to add ssh-key to the cloud-init, and this way it works directly, given that password authentication is disabled by default over ssh anyway (which I need to use with packer in order to install the ansible playbooks).