Thank you for replying,

I'm familiar with virt-sysprep/virt-customze and I want to systematically update packages of a fresh empty qcow2 image when making a template.

Ovirt already allows  to use virt-sysprep thanks to seal object.

I finally found the py script that deals with virt-sysprep: /usr/lib/python3.6/site-packages/vdsm/virtsysprep.py

from vdsm.virt.utils import LibguestfsCommand

_VIRTSYSPREP = LibguestfsCommand("virt-sysprep",
                                 "/usr/bin/virt-sysprep")


def sysprep(vm_id, vol_paths):
    """
    Run virt-sysprep on the list of volumes

    :param vol_paths: list of volume paths
    """
    args = ['--network', '--update']
    for vol_path in vol_paths:
        args.extend(('-a', vol_path))

    _VIRTSYSPREP.run(args, log_tag=vm_id)


Default script has no argument and just seal the vm, I simply added     args = ['--network', '--update'] to update package.

This modification implies to modify the script on all hosts and restart vdsmd, and is not persistent on vdsm/node upgrade. So I wondered if there was a way to make it persistent thanks to hooks.


Le 16/11/2021 à 13:25, Marcos Sungaila a écrit :

Hi Nathanaël,

 

With virt-sysprep, it is possible to install a package, update your template, activate a network connection, have SELinux relabel your system, and change other options.

Also is highly recommended to boot your template to ensure every last-minute change is working fine.

Before sealing the template, people use it to make all changes (update, package installation, user creation, network connections activation, etc…).

On the other hand, you can modify those options with virt-sysprep and launch an instance based on the template to validate your changes.

It is up to you to decide how to prepare your VM to seal/template it.

 

Regards,

Marcos

 

From: Nathanaël Blanchet <blanchet@abes.fr>
Sent: segunda-feira, 15 de novembro de 2021 17:19
To: users@ovirt.org
Subject: [External] : [ovirt-users] Virt-sysprep --update --network

 

Hello, 

As It is currently possible to seal a VM when templating with Sysprep, is it possible to extend virt-sysprep with other options as "--update --network" to update a qcow2 image with any hook?

-- 
Nathanaël Blanchet

Supervision réseau
SIRE
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5 	
Tél. 33 (0)4 67 54 84 55
Fax  33 (0)4 67 54 84 14
blanchet@abes.fr