[TUTORIAL] HOWTO: Scripts to make cloudbase work like cloudinit for your windows based instances

Hello everyone,

First if all thank you for great Proxmox and cloudbase. Coming from Hyper-V and Virtualizator it's a fresh and new.

Looking for some assistance with couldbase for Windows Server 2022 template where password is not set. To make it short I did following .

Using Proxmox 8.0.3
- Created new VM with settings:
Code:
4.00 GiB
4 (1 sockets, 4 cores) [host [vcpus=4]
Ww BIOS OVMF (UEF) 0 Display SPICE (qxl) Machine pc-q35-8.0 SCSI Controller VirtiO SCSI single CD/DVD Drive (ide2) localiso/WIN_2022_SERVER_EVALX64FRE_en-us.isomedia-cdrom.s. ○ CD/DVD Drive (sata1) localiso/virtio-win.iso,media=cdrom,size=709474K E Hard Disk (scsi0) storage:102/vm-102-disk-1.qcow2.jothread=1,size=32G Cloudlnit Drive (scsi1) storage:102/vm-102-cloudinit.qcow2,media=cdrom,size=4M = Network Device (neto) virtio=36-4E24 26.7F:41,bridge=vmbr0.frewall=1 E EFI Disk storage:102/vm-102-disk-0.qcow2,efitype=4m.pre-enrolled-keys=1,siz. E TPM State storage:102/v-102-disk-2.raw,size=4M,version=y2.0 @ Serial Port (seriall) socket

Installed on vm virtio drivers and guest agent along with cloubase init

Cloudbase conf

INI:
[DEFAULT]
username=Administrator
groups=Administrators
inject_user_password=true
first_logon_behaviour=no
rename_admin_user=true
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=COM1,115200,N,8
mtu_use_dhcp_config=true
ntp_use_dhcp_config=true
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=true
metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService
plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,
        cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin,
        cloudbaseinit.plugins.common.networkconfig.NetworkConfigPlugin,
        cloudbaseinit.plugins.windows.extendvolumes.ExtendVolumesPlugin, cloudbaseinit.plugins.common.userdata.UserDataPlugin,
        cloudbaseinit.plugins.windows.createuser.CreateUserPlugin,
        cloudbaseinit.plugins.common.setuserpassword.SetUserPasswordPlugin,
        cloudbaseinit.plugins.common.sshpublickeys.SetUserSSHPublicKeysPlugin,
        cloudbaseinit.plugins.windows.winrmlistener.ConfigWinRMListenerPlugin

Converted it to template without sysprep as i dont need it at this phase.

Created new VM with WHMCS from template and I got following working

- Username is changing properly or skipped if it's the same
- VM resources are allocated properly and disk resized properly (recovery partition was removed)
- Network static ip configuration has been assigned along with dns settings.
- hostname/vps or computer name is changed in Windows settings.

Only thing that is not working is password change. On cloudinit i have default template password and I get from Cloudbase logs that username or password were not correct and random password is being generated by cloudbase.

My guess is that password is maybe sent encrypted since this proxmox is not patched. But since I'm still not expert in proxmox I need your assistance to debug this issue.

How to see proxmox cloudinit data that is being sent to vm to check what password is being sent to Cloudbase?

If encrypted password is being sent what file do I need to patch and how since everything else is working except password.

Thanks
Proxmox does no longer need to be patched. This was implemented natively in PVE around a year ago.
Make sure you have the OS type of the VM correctly set.
 
Proxmox does no longer need to be patched. This was implemented natively in PVE around a year ago.
Make sure you have the OS type of the VM correctly set.
That's correct for versions above 8.2.4 but mine is lower. Double checked everything and it was not patched so I'm doing it now.
 
Back again just to confirm after manually custom patching Cloudinit.pm and Qemu.pm i got everything working.

Code:
Generated Metadata for Windows VMs:

{
  "uuid": "generated-uuid",
  "network_config": { "content_path": "/content/0000" },
  "meta": {
    "admin_pass": "cleartext-password",
    "admin_user": "username",
    "hostname": "vm-hostname",
    "instance_id": "generated-uuid",
    "public_keys": ["ssh-key1", "ssh-key2"]
  }
}
 
Hello everyone, could you please help me? I’ve been struggling with this for 7 days straight and don’t know what to do. I set up a virtual machine, installed Cloudbase, but after running sysprep and then cloning, I still log in with the same username and password, even though I specify custom settings in Cloud-Init. I’m a beginner, so maybe I didn’t configure the virtual machine correctly. VirtIO drivers and the guest agent are installed. Ideally, I want CloudInit to work, but it’s enough just to prompt for a password change

Proxmox version 8.4.1
Cloudbase-init 1.1.6

settings VM:
agent: 1
boot: order=ide0;ide2;net0
cores: 4
cpu: x86-64-v2-AES
ide0: local-4-256:119/vm-119-disk-0.qcow2,size=20G
ide1: local-4-256:119/vm-119-cloudinit.raw,media=cdrom
ide2: local-4-256:iso/virtio-win-0.1.266.iso,media=cdrom,size=707456K
machine: pc-q35-9.2+pve1
memory: 4196
meta: creation-qemu=9.2.0,ctime=1756317577
net0: e1000=BC:24:11:B6:E4:54,bridge=vmbr0,firewall=1
numa: 0
ostype: win10
scsihw: virtio-scsi-single
serial0: socket
smbios1: uuid=87e7bb60-4a20-485c-8348-0dd8006f8716
sockets: 1
vmgenid: 19fb8565-c722-4db2-a1db-e3d5990b10af

cloudbase-init:
[DEFAULT] username=Admin
groups=Administrators
inject_user_password=false
config_drive_raw_hhd=true
config_drive_cdrom=true
config_drive_vfat=true
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=COM1,115200,N,8
mtu_use_dhcp_config=true
ntp_use_dhcp_config=true
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=true
metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService, cloudbaseinit.metadata.services.httpservice.HttpService, cloudbaseinit.metadata.services.ec2service.EC2Service,
cloudbaseinit.metadata.services.maasservice.MaaSHttpService
# What plugins to execute.
plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,
cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin
# Miscellaneous.
allow_reboot=false # allow the service to reboot the system
stop_service_on_exit=false

cloudbase-init-unnatend:
[DEFAULT]
username=Admin
groups=Administrators
inject_user_password=false
config_drive_raw_hhd=true
config_drive_cdrom=true
config_drive_vfat=true
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=COM1,115200,N,8
mtu_use_dhcp_config=true
ntp_use_dhcp_config=true
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=true
metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService,
cloudbaseinit.metadata.services.httpservice.HttpService,
cloudbaseinit.metadata.services.ec2service.EC2Service,
cloudbaseinit.metadata.services.maasservice.MaaSHttpService
# What plugins to execute.
plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,
cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin
# Miscellaneous.
allow_reboot=false # allow the service to reboot the system
stop_service_on_exit=false