Creating Windows Virtual Machines Using Cloudbase-Init

You can create Windows virtual machines in SUSE Virtualization using Cloudbase-Init. To standardize provisioning and efficiently deploy multiple instances, you must create a reusable Windows virtual machine template from a base image.

Prerequisites

Configuration workflow

Creating a Windows QCOW2 image using a VirtIO driver

Create a Windows virtual machine in SUSE Virtualization using disks configured with the VirtIO driver.

The target installation disk must use the VirtIO bus type. Otherwise, the Windows installer will fail to detect the disk.

  1. On the SUSE Virtualization UI, go to Images and upload the following:

    • Windows ISO file

    • VirtIO driver ISO file

  2. Go to Virtual Machines and create a virtual machine with three volumes.

    Volume Source Bus Type

    1

    Windows ISO file

    SATA

    2

    VirtIO driver ISO file

    SATA

    3

    Disk where Windows will be installed

    VirtIO

  3. Start the virtual machine, and then open the console.

  4. Follow the instructions on the Windows installation wizard.

    When prompted to select an installation target, load the VirtIO driver from the attached ISO file if the disk is not automatically detected.

  5. Log in to the Windows guest operating system and install all remaining drivers using the attached VirtIO ISO file.

Installing and configuring Cloudbase-Init

Install and configure Cloudbase-Init on the Windows guest operating system.

  1. Download and run the Cloudbase-Init installer.

  2. Follow the instructions on the Cloudbase-Init setup wizard.

  3. On the Configuration options screen, you must select Run Cloudbase-Init service as LocalSystem.

  4. Click Install.

    You must keep the setup wizard window open after installation is completed. Do not click Finish.

  5. Access C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf.

  6. Edit cloudbase-init.conf and cloudbase-init-unattend.conf.

    Paste the following settings into each file.

    • cloudbase-init.conf:

      [DEFAULT]
      username=Admin
      groups=Administrators
      inject_user_password=true
      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
      logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
      logfile=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.nocloudservice.NoCloudConfigDriveService,cloudbaseinit.metadata.services.configdrive.ConfigDriveService,cloudbaseinit.metadata.services.base.EmptyMetadataService
    • cloudbase-init-unattend.conf:

      [DEFAULT]
      username=Admin
      groups=Administrators
      inject_user_password=true
      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
      logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
      logfile=cloudbase-init-unattend.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\
      plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin,cloudbaseinit.plugins.windows.extendvolumes.ExtendVolumesPlugin
      check_latest_version=false
      allow_reboot=false
      stop_service_on_exit=false
      
      metadata_services=cloudbaseinit.metadata.services.nocloudservice.NoCloudConfigDriveService,cloudbaseinit.metadata.services.configdrive.ConfigDriveService,cloudbaseinit.metadata.services.base.EmptyMetadataService
  7. After saving the changes, go back to the Cloudbase-Init setup wizard.

  8. Select Run Sysprep to create a generalized image. and Shutdown when Sysprep terminates..

  9. Click Finish.

Do not start the virtual machine before performing the next set of steps.

Exporting and converting the operating system volume

Export the volume containing the operating system files and core system directories, and convert it to an image for creating other virtual machines.

  1. On the SUSE Virtualization UI, go to Volumes.

  2. Locate the operating system volume and select ⋮ → Export Image.

  3. In the Export to Image window, configure the required settings and click Create.

  4. Go to Images and verify that the image was created.

Ensure that the image state changes to Ready before using it to create a virtual machine.

Creating the cloud-init user-data YAML

Create a cloud configuration template to be used with the Windows virtual machine.

  1. On the SUSE Virtualization UI, go to Advanced → Cloud Config Templates.

  2. Click Create.

  3. On the Create:Cloud Config Template screen, perform the following actions:

    • Basics: Specify the namespace and a unique name for the virtual machine.

    • Template Settings: Under User Data, type the cloud-config YAML that handles operating system-level tasks.

  4. Click Create.

The following is an example of cloud-config YAML that can be used in a template.

#cloud-config
set_hostname: winserver01
set_timezone: America/Sao_Paulo
ntp:
  enabled: true
  servers:
    - a.st1.ntp.br
    - b.st1.ntp.br
write_files:
  - path: C:\status.txt
    content: Initial Configuration Concluded!
    encoding: utf-8
users:
  - name: tux
    password: StrongPassw0rd
    groups:
      - Administrators
runcmd:
  - powershell.exe -Command "Install-WindowsFeature -Name Web-Server -IncludeManagementTools"
  - powershell.exe -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"
  - powershell.exe -Command "Start-Service sshd"
  - powershell.exe -Command "Set-Service -Name sshd -StartupType Automatic"
  - powershell.exe -Command "Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name 'fDenyTSConnections' -Value 0"
  - powershell.exe -Command "Enable-NetFirewallRule -DisplayGroup 'Remote Desktop'"

This cloud-config YAML automatically creates a Windows virtual machine with predefined settings on initial boot, eliminating the need for manual post-installation configuration.

  • Sets the hostname to winserver01

  • Sets the timezone to America/Sao_Paulo

  • Enables NTP synchronization using a.st1.ntp.br and b.st1.ntp.br

  • Creates a file named status.txt in C: with the message Initial Configuration Concluded!

  • Creates a local user account named tux and adds it to the Administrators group

  • Installs Internet Information Services (IIS)

  • Installs, starts, and enables the OpenSSH Server

  • Enables Remote Desktop (RDP) and the corresponding Windows Firewall rules

The resulting Windows virtual machine is ready to host web applications and can be accessed remotely using both SSH and RDP.

Creating a Windows virtual machine using the cloud configuration template

When you create a new Windows virtual machine using the cloud configuration template, SUSE Virtualization automatically applies the predefined settings.

  1. On the SUSE Virtualization UI, go to Virtual Machines and click Create.

  2. On the Create:Virtual Machine screen, perform the following actions:

    • Header: Specify the namespace and a unique name for the virtual machine.

    • Basics: Assign the required CPU and memory resources.

    • Volumes: In the Image Volume section, select the Windows image that you converted earlier.

    • Network: Configure the settings according to your environment’s requirements.

    • Advanced Options: In the Cloud Config section, select your template from the User Data Template list.

  3. Click Create.

The virtual machine will restart multiple times while Sysprep runs and Cloudbase-Init applies the settings defined in the cloud configuration template. Once the provisioning process is completed, you can log into the virtual machine to verify that the settings were correctly applied.