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

hi gecoit.
I will recive error with dir "Program Files (x86) " not found ,when i run ModifyConf.ps1 on x86 system.
View attachment 37072
Hey, I think it's OS 32-64 bit detection problem. Try changing this line:
Code:
$fileNames = Get-ChildItem "C:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\conf" -Recurse | select -expand fullname
to this
Code:
$fileNames = Get-ChildItem "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf" -Recurse | select -expand fullname
Can you tell me if your virtual machine is indeed 32bit so I can update the script?
 
Upstreaming likely would've prevented the mentioned issue, which was triggered by a recent refactoring.
You can use this file to manually add the patch to the new version, there are also explications on what every function does.
https://git.geco-it.net/GECO-IT-PUBLIC/Geco-Cloudbase-Init/src/branch/master/MANUALPATCH.md

If you already have the patches and want to contribute back, why not upstream it?
https://pve.proxmox.com/wiki/Developer_Documentation

Hello everyone, sorry for the late reply. We are a bit busy with a lot of projects going on.

So we are actually using this patch with 6.4 in production. We have done the tests for version 7.1 in a lab environment, but we are not in production with 7.1 or 7.2.

We have spoken about up streaming it, but I suppose there are some points that need to be treated in order to make a commit. Like clear text password and readopting to version 7.2 etc. We actually don't really have time to do it right now, but will seek an opportunity to do it in the future.
 
Last edited:
  • Like
Reactions: Bruno Garcia
Going through to see if I can get it running on 7.2. Documentation misses out the following lines from Qemu.pm

Code:
 my $conf = PVE::QemuConfig->load_config($vmid);
 my $ostype = $conf->{ostype};
I've added those lines in manual patch.
I've just downgraded qemu-server, and it's working at PvE 7.2

apt-install qemu-server=7.1-4

The incompatibility is at the qemu-server
qemu-server is the package that installs and updates those files.
 
I've added those lines in manual patch.

qemu-server is the package that installs and updates those files.

Cheers, appreciate it!

Other thing I've noticed is Cloud-Init now offers to install as a service from the start. Is that preferred or does it break anything vs running the script you have to change it over?

So far no luck in 7.2 following the instructions carefully. Everything looks like it works but cloning the machine just fires it up with the same account and login details as it had in the template. Given we're running an OOBE sysprep this seems pretty unusual.

I've reverted all changes and am going to try again from scratch to see how that goes.
 
It does not work on latest release proxmox 7.2-4.

Not to mention that after manually patching, a lot of errors show up regarding Cloudinit.pm when trying to regenerate a cloudinit drive for a VM.
This is reffering to: sub configdrive2_gen_metadata {

Password for windows administrator is never set.

Used the guide exactly as written in the docs, no luck on latest release.
Maybe you should check and make the neccessary changes.

I used windows server 2019 on my vm.
 
Hi gecoit,

I have tried to use your script but it doesn't create the windows Image correctly. And, I have tried multiple times.

once I put all the script you given into /LocalScript/ but it doesn't function well. And, how to excute the password from proxmox cloud-init once I edit it.
 
It does not work on latest release proxmox 7.2-4.
Why can't you make everything work out of the box for Windows?
There is a need for Windows to transfer the password and network settings
 
For proxmox 7.2+

Code:
root@pve1:~# pveversion
pve-manager/7.2-7/d0dd0e85 (running kernel: 5.15.39-4-pve)

You can use this file to manually add the patch to the new version, there are also explications on what every function does.
https://git.geco-it.net/GECO-IT-PUBLIC/Geco-Cloudbase-Init/src/branch/master/MANUALPATCH.md

It shoud modify `sub generate_configdrive2` and `sub dump_cloudinit_config` in MANUALPATCH.md, like:


Perl:
# For sub generate_configdrive2
if (!defined($meta_data)) {
-       $meta_data = configdrive2_gen_metadata($user_data, $network_data);
+       $meta_data = configdrive2_gen_metadata($conf, $vmid, $user_data, $network_data);
     }


# For sub dump_cloudinit_config
        } else {
            my $network = configdrive2_network($conf);
-            return configdrive2_gen_metadata($user, $network);
+            return configdrive2_gen_metadata($conf, $vmid, $user, $network);
        }


because `sub configdrive2_gen_metadata` has changed.
 
Last edited:
Patch for proxmox 7.2+

Code:
root@pve1:~# apt show qemu-server
Package: qemu-server
Version: 7.2-4

root@pve1:~# pveversion
pve-manager/7.2-7/d0dd0e85 (running kernel: 5.15.39-4-pve)
 

Attachments

  • Like
Reactions: Vpsradio
Patch for proxmox 7.2+

Code:
root@pve1:~# apt show qemu-server
Package: qemu-server
Version: 7.2-4

root@pve1:~# pveversion
pve-manager/7.2-7/d0dd0e85 (running kernel: 5.15.39-4-pve)
Hi

Do you have any cloudbase-init patches for 7.3+ ?
 
  • Like
Reactions: ittopp
Would there be a process/interest to actually upstream these fixes? It does sounds like something Proxmox could benefit from?
 
I am personally not proficient with Perl, so I am not of much help, but given the code is available here, would the Proxmox team be able to adopt it?

From reading the wiki about submitting the code, the process might be a bit too convoluted for people to bother, maybe its easier if a internal developer adopts it?
Copyright is an issue with that, you cannot just take arbitrary code posted somewhere and integrate it.
The process consist of sending a signed CLA PDF once per mail to office@proxmox.com, and then sending a simple patch to pve-devel@lists.proxmox.com, takes not more than 5 minutes so IMO not really that convoluted - it's a process that's the same with a lot of open source projects, especially the bigger ones (kernel, qemu, postgres, ...).
 
Thank you @gecoit for your work, it literally saved me days of work!

However, I have identified a couple of issues that need to be addressed
  • The 99EjectDrive.py file is not functioning properly
  • The Disk Extender plugin is not working due to the recovery partition.
To rectify the first issue, I will be attaching a working version of the file.
To resolve the second issue, you can either follow any online tutorials that explain how to delete the recovery partition or follow the instructions provided below.
  1. Run "cmd.exe" as Administrator
  2. Run "diskpart.exe"
  3. Type "list disk" and press enter
  4. Type "select disk X" (where X is the number of your OS disk. You should have 2 disks if you have attached the cloud init drive during the vm's creation) and press enter
  5. Type "list volume" and press enter
  6. Type "select volume X" (where X is the 3rd/last volume available with 520mb of space) and press enter
  7. Type "delete volume override" and press enter
Please note that these instructions have been tested on a Windows 10 VM.
 

Attachments

Copyright is an issue with that, you cannot just take arbitrary code posted somewhere and integrate it.
The process consist of sending a signed CLA PDF once per mail to office@proxmox.com, and then sending a simple patch to pve-devel@lists.proxmox.com, takes not more than 5 minutes so IMO not really that convoluted - it's a process that's the same with a lot of open source projects, especially the bigger ones (kernel, qemu, postgres, ...).
And what if someone else does it, so not proxmox or the poster of arbitrary code themselves?

I might give it a try then, in the hope that once it is upstream it stays maintained better.

While not dealing daily with Windows myself I do have to offer it to my users and this would take a lot of burden and hacky solutions away from production environments.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!