Finally Cloudbase Init windows servers

getting this while patchin

# patch /usr/share/perl5/PVE/QemuServer/Cloudinit.pm < cloudinit.patch
patching file /usr/share/perl5/PVE/QemuServer/Cloudinit.pm
Hunk #1 FAILED at 37.
1 out of 4 hunks FAILED -- saving rejects to file /usr/share/perl5/PVE/QemuServer/Cloudinit.pm.rej
 
A quick update: We have snippets support in qemu-server 5.0-48
With it you can specify custom metadata, userdata or networkdata files to replace the ones generated.
If you have 5.0-48 or a higher version you can set the files via 'qm set --cicustom "network=<storage>:snippets/<file>" where storage is the one with snippets support (activate in Datacenter -> Storage -> <Storage>). Only directory storage is available for snippets.

You can mix and match any of the 3 kinds ("network=...,user=..." or "meta=...,user=..." and so on). For more information take a look at 'man qm' and look for 'cicustom'.

For now there's no possibility to merge custom data with generated data and we don't yet have any functionality to dump the generated config (as basis for a custom one).

The '-iso-level', '3' patch for genisoimage is still required for now.
 
I am using Hostbill to provision KVM windows + cloud-init been playing around for few days now still no luck
 
OK here is a patch I have used it for Windows 2012R2 and Windows 2016 I m now trying 2019
IT creates windows only functions in the Cloudinit.pm Linux nocloud and configdrive2 still works
Make sure in your template you set the option to a windows one and then this comes into play

Password kind of works but only plain text eg you need to edit the cipassword:
/etc/pve/qemu-server/xxx.conf

To get arouund this I simplke enable winrm and use some ansible provsioing to do all I want



Backup the
/usr/share/perl5/PVE/QemuServer/Cloudinit.pm
cp /usr/share/perl5/PVE/QemuServer/Cloudinit.pm /root/Cloudinit.pm.org

upload the cloudinit.patch ( I had to add .txt to get this web upload to work
in the directory you uploaded it

patch /usr/share/perl5/PVE/QemuServer/Cloudinit.pm < cloudinit.patch
systemctl restart pvedaemon

The reason dns was not working is the orgianal was using dns_nameservers needs to be dns-nameservers


On your windows image that you are creating start I up I assume you have added Vioscii NetKVM and other drivers you need you will at least need
Virtio Serial

In the Proxmox hardware for that image add a serial port 0 ( make sure you slect one when you install cloudbase-init )


start your image install Cloud base init
cd \

C:\powershell
C:\Set-ExecutionPolicy Unrestricted
C:\Invoke-WebRequest -UseBasicParsing https://www.cloudbase.it/downloads/CloudbaseInitSetup_Stable_x64.msi -OutFile cloudbaseinit.msi

Wait for the download
.\cloudbaseinit.msi

del .\cloudbaseinit.msi

select the serial port
Don't do system prep or shutdown

Now edit the cloudbaseinit config there are two
cloudbase-init
add meta data service if missing
metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService

add the plugins you need
for mine i have
plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin,cloudbaseinit.plugins.windows.extendvolumes.ExtendVolumesPlugin

you may also what set password and create user
cloudbaseinit.plugins.windows.createuser.CreateUserPlugin
cloudbaseinit.plugins.windows.setuserpassword.SetUserPasswordPlugin


cloudbase-init-unattend
edit meta data services
metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService

nothing to do on the plugins here

Now system prep the image
cd C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf
C:\Windows\System32\sysprep\sysprep.exe /generalize /oobe /unattend:Unattend.xml

now it should work when you start the image

If you want to make changes to that config with that same image first
Remove KEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cloudbase Solutions\Cloudbase-Init
that will allow cloudinit to rerun

but if you want the image to be fresh
Remove KEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cloudbase Solutions\Cloudbase-Init
and run the sysprep again

I'm using pve 5.4 and get this problem

root@pve:~# patch /usr/share/perl5/PVE/QemuServer/Cloudinit.pm < cloudinit.patch
patching file /usr/share/perl5/PVE/QemuServer/Cloudinit.pm
Hunk #1 succeeded at 49 with fuzz 1 (offset 12 lines).
Hunk #2 succeeded at 149 (offset 12 lines).
Hunk #3 succeeded at 234 (offset 12 lines).
Hunk #4 FAILED at 284.
1 out of 4 hunks FAILED -- saving rejects to file /usr/share/perl5/PVE/QemuServer/Cloudinit.pm.rej

any update?

Thank you
 
A quick update: We have snippets support in qemu-server 5.0-48
With it you can specify custom metadata, userdata or networkdata files to replace the ones generated.
If you have 5.0-48 or a higher version you can set the files via 'qm set --cicustom "network=<storage>:snippets/<file>" where storage is the one with snippets support (activate in Datacenter -> Storage -> <Storage>). Only directory storage is available for snippets.

You can mix and match any of the 3 kinds ("network=...,user=..." or "meta=...,user=..." and so on). For more information take a look at 'man qm' and look for 'cicustom'.

For now there's no possibility to merge custom data with generated data and we don't yet have any functionality to dump the generated config (as basis for a custom one).

The '-iso-level', '3' patch for genisoimage is still required for now.

In PVE 6.0 the 'iso-level 3' option is already passed to genisoimage. As a result network config should work out of the box now with cloudbase-init.
I couldn't reliably get DNS working, so this has not been patched yet.
In addition to snippets, we now also offer the option to dump the generated config that can be used as a base for a custom config file.
'qm cloudinit dump <vmid> <user|network|meta>' is the command. With this and snippets you can create you own custom config based on the cloudinit-base documentation.

Please test this and if you do get IPv6 DNS Server working, please let us know. Feedback and success stories are welcome.
 
  • Like
Reactions: TND
Failed to create password
 

Attachments

  • cloudbase-init.log
    47.2 KB · Views: 14
  • cloudbase-init-unattend.log
    16.7 KB · Views: 8
Hi,

I'm trying this patch with Proxmox 6.0 but the error below is happening when I apply the patch:

patching file /usr/share/perl5/PVE/QemuServer/Cloudinit.pm
Hunk #1 FAILED at 37.
Hunk #2 succeeded at 149 (offset 12 lines).
Hunk #3 succeeded at 241 with fuzz 1 (offset 19 lines).
Hunk #4 FAILED at 284.
2 out of 4 hunks FAILED -- saving rejects to file /usr/share/perl5/PVE/QemuServer/Cloudinit.pm.rej
 
Cloudinit with Windows 2019 doesn't work!!!!


Serial Debug attached.
 

Attachments

  • console-debug.txt
    35.3 KB · Views: 19
Last edited:
because you have allready all that config lines, please check manualy to undersand what i say :)
 
Hi I have a question, why i have into content/0000 this format:

Code:
auto lo
iface lo inet loopback

        dns_nameservers 8.8.8.8
        dns_search name.tld
auto eth0
iface eth0 inet static
        address x.x.x.x
        netmask 255.255.255.255
        gateway x.x.x.1
        dns-nameservers 8.8.8.8

and into vmconfig i have ostype=win8 (i select win 2012 from gui)

This is the output from xterm

Code:
2020-02-17 17:26:39.464 2004 DEBUG cloudbaseinit.utils.classloader [-] Loading class 'cloudbaseinit.osutils.windows.WindowsUtils' load_class c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\utils\classloader.py:27
                                                                        2020-02-17 17:26:39.479 2004 DEBUG cloudbaseinit.metadata.services.base [-] Using cached copy of metadata: 'openstack/latest/meta_data.json' _get_cache_data c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\metadata\services\base.py:92
        2020-02-17 17:26:39.479 2004 INFO cloudbaseinit.utils.debiface [-] Parsing Debian config...
              auto lo
                     iface lo inet loopback

                                                   dns_nameservers 8.8.8.8
                                                                                  dns_search domain.tld
                auto eth0
                         iface eth0 inet static
                                                       address x.x.x.x
                                                                                    netmask 255.255.255.255
                              gateway x.x.x.1
                                                         dns-nameservers 8.8.8.8

                                                                                2020-02-17 17:26:39.495 2004 DEBUG cloudbaseinit.utils.debiface [-] Found new interface: {'mac': None, 'gateway6': None, 'dnsnameservers': ['8.8.8.8'], 'broadcast': None, 'netmask6': None, 'address': '89.41.176.100', 'gateway': '89.41.176.1', 'name': 'eth0', 'address6': None, 'netmask': '255.255.255.255'} _add_nic c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\utils\debiface.py:103
                                                                                   2020-02-17 17:26:40.057 2004 INFO cloudbaseinit.plugins.common.networkconfig [-] Configuring network adapter F6:26:3A:EB:25:AD
                                       2020-02-17 17:26:40.792 2004 DEBUG cloudbaseinit.osutils.windows [-] Setting static IP address set_static_network_config c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\osutils\windows.py:766
                  2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init [-] plugin 'NetworkConfigPlugin' failed with error '('Cannot set static IP address on network adapter (%d)', 66)'
               2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init [-] ('Cannot set static IP address on network adapter (%d)', 66)
                                                2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init Traceback (most recent call last):
                                                   2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\init.py", line 65, in _exec_plugin
                                                                    2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init     shared_data)
                                                     2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\networkconfig.py", line 155, in execute
     2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init     nic.dnsnameservers
                                                                                 2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\osutils\windows.py", line 771, in set_static_network_config
                                      2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init     ret_val)
                   2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init cloudbaseinit.exception.CloudbaseInitException: ('Cannot set static IP address on network adapter (%d)', 66)
           2020-02-17 17:26:40.854 2004 ERROR cloudbaseinit.init
                                                                 2020-02-17 17:26:40.901 2004 DEBUG cloudbaseinit.metadata.services.configdrive [-] Deleting metadata folder: 'C:\\Users\\CLOUDB~1\\AppData\\Local\\Temp\\tmphfh3zsh3' cleanup c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\metadata\services\configdrive.py:86
                         2020-02-17 17:26:40.901 2004 INFO cloudbaseinit.init [-] Plugins execution done
                   2020-02-17 17:26:40.901 2004 INFO cloudbaseinit.init [-] Stopping Cloudbase-Init service
                      2020-02-17 17:26:43.901 2004 DEBUG cloudbaseinit.osutils.windows [-] Stopping service cloudbase-init stop_service c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\osutils\windows.py:942


Please help me if it's possible.

Thanks
 
Did anyone fix "Cannot set the password in the metadata as it is not supported by this service"
I'm still getting it even though it's clearly a plaintext password, I can see it in the config drive
 

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!