Cloud-init doesn't work?!?

austin17427

Member
Jun 4, 2020
16
0
21
54
Hi,
First of all Proxmox is the best!!! Thanks for your hard work.
I'm trying to configure cloud-init and clone an vm from that template (with Ansible). No matter what I do, I couldn't get my cloud-init working.
Step by step;
- I download and prep a Ubuntu 22.04 image
template_customize_statements: - virt-customize -a {{ template_image_name }} --update - virt-customize -a {{ template_image_name }} --install qemu-guest-agent - virt-customize -a {{ template_image_name }} --root-password password:secret - "# important step so your clones get unique mac address / network details." - virt-customize -a {{ template_image_name }} --run-command '>/etc/machine-id' template_qm_statements: - "# Create vm + customize See https://pve.proxmox.com/pve-docs/qm.1.html" - qm create {{ template_vmid }} --name {{ template_vm_name }} --cores {{ template_vm_cores }} --memory {{ template_vm_mem }} --net0 virtio,bridge=vmbr0,firewall=1 - qm importdisk {{ template_vmid }} {{ template_image_name }} {{ template_vm_storage }} - qm set {{ template_vmid }} --scsihw virtio-scsi-pci --scsi0 {{ template_vm_storage }}:vm-{{ template_vmid }}-disk-0 - qm set {{ template_vmid }} --cicustom "meta=local:snippets/user-data.yaml" - qm set {{ template_vmid }} --ide2 {{ template_vm_storage }}:cloudinit - qm set {{ template_vmid }} --boot order=scsi0 - qm set {{ template_vmid }} --serial0 socket --vga serial0 - qm set {{ template_vmid }} --agent enabled={{ template_vm_agent }} - qm resize {{ template_vmid }} scsi0 {{ template_vm_disksize }} - qm template {{ template_vmid }}
- Full clone from the template
- I can't login with my designated user, default user. So I put a simple password on root (see above)
- When I check the /var/log/cloud-init-output.log there's no mention of my user?
- I verified the snippet is being written and looks to be correct.

Here's my user-data.yaml

#cloud-config # See https://cloudinit.readthedocs.io/en/latest/reference/examples.html chpasswd: expire: false users: - name: ansible groups: sudo shell: /bin/bash sudo: ['ALL=(ALL) NOPASSWD:ALL'] lock_passwd: false passwd: {{ template_ci_password }} ssh_authorized_keys: - {{ template_ansible_pub_key | from_yaml }} manage_etc_hosts: true manage_resolv_conf: true resolv_conf: nameservers: {{ nameservers | from_yaml }} searchdomains: {{ search_domains | from_yaml }} timezone: US/Chicago

I don't know what I'm doing wrong? Thanks in advance for your help!!
 

Attachments

- qm set {{ template_vmid }} --cicustom "meta=local:snippets/user-data.yaml"
why are you assigning what appears to be a user-data to meta option?
I suspect you want user= (man qm)
Code:
--cicustom [meta=<volume>] [,network=<volume>] [,user=<volume>] [,vendor=<volume>]
           cloud-init: Specify custom files to replace the automatically generated ones at start.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox