mode: 0755
path: "/usr/local/bin/vsphere-hostname.sh"
contents:
  inline: |
    #!/usr/bin/env bash
    set -e

    if vm_name=$(/bin/vmtoolsd --cmd 'info-get guestinfo.hostname'); then
        /usr/bin/hostnamectl --transient set-hostname ${vm_name}
    fi
