Finally Cloudbase Init windows servers

Discussion in 'Proxmox VE: Installation and configuration' started by Craig St George, Nov 14, 2018.

  1. Craig St George

    Joined:
    Jul 31, 2018
    Messages:
    43
    Likes Received:
    4
    OK I finally got some things to Work using Cloudbase-init 0.9.11 eg the current stable

    Here is what works
    Extending the Disks
    Setting up the network
    Setting the hostname
    Enabling WRM if you need that
    Setting the Password ( but it can only support Plain Text Password ) so the hash in /etc/pve/qemu/vmid.conf would need to be changed to plain text the good thing is the Default behavior for Cloudbase it to require password change on first logon but you can change that.

    Here is what does not work
    Creating a new user ( Openstack configdrive in cloudbase is not supporting that)
    Setting the FQDN once again they do not support that

    There are other things that I did not fully test them like WRM certs and NTP as I was not using that
    But they seem to work

    But now for the said news first of All it will not work at all out of the box as Proxmox ISO is not read at all
    that is a simple fix

    /usr/share/perl5/PVE/QemuServer/Cloudinit.pm needs to be changed so the ISO is recognized
    in
    commit_cloudinit_disk {
    I had to change the run_command([['genisoimage' to include an ISO level
    run_command([['genisoimage','-iso-level', '3', '-R', '-V', $label, $path],

    Now the disk gets read and also the network setup works


    The Second more important problem is the settings in USER_DATA are not used at all
    So Password hostname etc will not work
    eg. #cloud-config
    They read it but they only support a small about of the features in the user_data e.g
    https://cloudbase-init.readthedocs.io/en/latest/userdata.html#userdata

    They expect the data to be in the meta_data.json currently that only has
    "uuid": "$uuid",
    "network_config": { "content_path": "/content/0000" },


    I added in
    "hostname":
    and
    "admin_pass" in Json format and now that works can also add in SSH keys if you need

    But of course this required hacking the Perl code

    I m not sure how to work around that password problem as if that also could be done then the it would be almost usable

    I was thinking changing the code that makes the /etc/pve/qemu-server/vm.id.conf so if the server was windows allow plain text its not ideal but could work

    But even the changes I made for the ISO file and the meta_data.json would be good to get into the core so we can use windows a bit better else I need to hack that file for each new Hypervisor

    Thanks
     
  2. dcsapak

    dcsapak Proxmox Staff Member
    Staff Member

    Joined:
    Feb 1, 2016
    Messages:
    3,034
    Likes Received:
    281
    great that that works ! (i never got it to work myselft properly)

    does it still work on linux with your changes?
    if yes (or even if no), you could post your patches on the pve-devel list (see https://pve.proxmox.com/wiki/Developer_Documentation )
    to see if we can integrate them (if they are not too much), also maybe some iterations are needed

    this way all would benefit from it
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Craig St George

    Joined:
    Jul 31, 2018
    Messages:
    43
    Likes Received:
    4
    It should still work well the NoCloud does for sure let me test with the Configdrive and make some changes if needed
    Then I will submit the code . Probably next week as so busy lol

    I also have a document with the info about the config files on the Windows side and the correct way to install the Windows program if that is need
     
  4. dlimbeck

    dlimbeck Proxmox Staff Member
    Staff Member

    Joined:
    Aug 1, 2018
    Messages:
    96
    Likes Received:
    3
    Either that or a patch to the pve-docs repository would be appreciated. Thank you for putting in all that effort.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Craig St George

    Joined:
    Jul 31, 2018
    Messages:
    43
    Likes Received:
    4
    Sorry for the delay on this I did a lot more looking and found some issues with the DNS servers and there are a few other things
    As there are a lot of differences I will refactor my changes so that IF its windows it will use a different set of functions that way it will not have a problem with the existing config drive 2 ( but I would think most people would be using no cloud anyway for Linux )

    The things that work are
    Networking setup
    Expand disk
    Add user ( but not the one you have in the Proxmox only the One in the Cloud-base init conf)
    Set that users password ( but the password needs to be plain text so need to edit the config)
    Enable WinRM
    Updates

    It would be nice to have another CI field to add WRM cert though as you cant use the SSH one and that is for somthing else anywhay
    but SSH cert will not vaildate as a SSL public cert

    Anyway it basicly works for me now and I use it to enable winrm then I use Ansible to do the rest of the provisioning

    Now for the docs and the diffs
     
  6. Lucian

    Lucian New Member

    Joined:
    Nov 7, 2017
    Messages:
    10
    Likes Received:
    1
    Hello,

    Are there any updates to this?
    I'm trying to get some Windows templates running, but cloudbase-init does nothing for me.
    Is there configuration required on cloudbase side? I just ran it, it sysprepped by system, but it has not set any IPs, users, password nothing.
    I tried with cloud-init both in nocloud and configdrive2 mode, no luck.

    Now that Windows supports OpenSSH server I am tempted to ship templates with it enabled + bundled ssh keys and do my (initial) admin over that.
     
  7. Craig St George

    Joined:
    Jul 31, 2018
    Messages:
    43
    Likes Received:
    4
    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
     

    Attached Files:

  8. Craig St George

    Joined:
    Jul 31, 2018
    Messages:
    43
    Likes Received:
    4
  9. Lucian

    Lucian New Member

    Joined:
    Nov 7, 2017
    Messages:
    10
    Likes Received:
    1
    Thanks, I'll try my luck soon enough! :)
     
  10. Lucian

    Lucian New Member

    Joined:
    Nov 7, 2017
    Messages:
    10
    Likes Received:
    1
    I must be even more terrible with Windows than I thought, but after all the modifications, I still got no success whatsoever. No user got created, no password set, no IP, host, nothing. All I got after sysprep was to be asked a new password for the Administrator.

    I am giving up on this solution for now and will try to use other methods.
     
  11. Craig St George

    Joined:
    Jul 31, 2018
    Messages:
    43
    Likes Received:
    4
    In the VM you set the Options to Windows OS right
    you have also added a serial device to the windows server and selected that com 1 when you did the install of cloudbase

    then when you start the VM you can see the output by going to the console and select the xterm.js

    Was the DNS setup and also the new user would probable be created and check that password you used with that
     
  12. encore

    encore Member

    Joined:
    May 4, 2018
    Messages:
    33
    Likes Received:
    0
    when I try to execute your patch I get:
    Could you upload your complete Cloudinit.pm @Craig St George?
     
  13. Lucian

    Lucian New Member

    Joined:
    Nov 7, 2017
    Messages:
    10
    Likes Received:
    1
    His patch is for 5.3.. if you are on 5.2 it won't apply cleanly. Upgrade.
     
  14. encore

    encore Member

    Joined:
    May 4, 2018
    Messages:
    33
    Likes Received:
    0
    thanks, worked!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice