
Hi, Has anyone an idea what's the easiest way to sysprep Linux (CentOS 6 and RHEL 6) machines? The use case is the following: I want to create a lot of virtual machines (e.g. 100) by cloning from one template. So I create a master vm, create a template and a pool with 100 vms assigned to it and set all 100 vms to prestarted. The problem is now, that when I run "sys-unconfig" before creating the template, which does a "touch /.unconfigured" I have to go through the sysconfig-tui and set a new root password for all 100 hosts. So what I'm looking for is a script like the sysprep tool for windows which sets parameters for me automatically. I only need to change: * Hostname + set DHCP_HOSTNAME in ifcfg-eth0 (Hostname == Pool-VM-Name) for some dhcp/ddns magic :) * Clear udev network-rules * remove SSH-Keys * Remove RHN ID and join Satellite/Spacewalk-server * root-password,... should stay the same My first question is: does oVirt provide such a functionality for Linux guest out-of-the-box? I couldn't find one. I think I could solve this with virt-sysprep and virt-file, but I'm unsure if I can use it with oVirt (or only with plain libvirt): http://libguestfs.org/virt-sysprep.1.html http://libguestfs.org/virt-edit.1.html For this tools it's required that the vm is not running, as it changes files on the disk. If I'm using a before-vm-start hook, it should be save to access the disk and change content with virt-sysprep/virt-file, right? But do I have access to the disk in a before-vm-start hook? If using NFS storage I should be able to access all disks on the NFS-share, but for iSCSI/FC-LUNS - are they available on the hypervisor in this stage? Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami :) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so.... Thanks a lot for suggestions, René

Hello, I usually does this : http://www.kermit.fr/lofic/snipper/20/ Regards, Louis Coilliot 2013/8/19 René Koch (ovido) <r.koch@ovido.at>
Hi,
Has anyone an idea what's the easiest way to sysprep Linux (CentOS 6 and RHEL 6) machines?
The use case is the following: I want to create a lot of virtual machines (e.g. 100) by cloning from one template. So I create a master vm, create a template and a pool with 100 vms assigned to it and set all 100 vms to prestarted.
The problem is now, that when I run "sys-unconfig" before creating the template, which does a "touch /.unconfigured" I have to go through the sysconfig-tui and set a new root password for all 100 hosts.
So what I'm looking for is a script like the sysprep tool for windows which sets parameters for me automatically. I only need to change: * Hostname + set DHCP_HOSTNAME in ifcfg-eth0 (Hostname == Pool-VM-Name) for some dhcp/ddns magic :) * Clear udev network-rules * remove SSH-Keys * Remove RHN ID and join Satellite/Spacewalk-server * root-password,... should stay the same
My first question is: does oVirt provide such a functionality for Linux guest out-of-the-box? I couldn't find one.
I think I could solve this with virt-sysprep and virt-file, but I'm unsure if I can use it with oVirt (or only with plain libvirt): http://libguestfs.org/virt-sysprep.1.html http://libguestfs.org/virt-edit.1.html
For this tools it's required that the vm is not running, as it changes files on the disk. If I'm using a before-vm-start hook, it should be save to access the disk and change content with virt-sysprep/virt-file, right? But do I have access to the disk in a before-vm-start hook? If using NFS storage I should be able to access all disks on the NFS-share, but for iSCSI/FC-LUNS - are they available on the hypervisor in this stage?
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami :) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....
Thanks a lot for suggestions, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

I DO this, sorry. 2013/8/19 Louis Coilliot <louis.coilliot@think.fr>
Hello,
I usually does this :
http://www.kermit.fr/lofic/snipper/20/
Regards,
Louis Coilliot
2013/8/19 René Koch (ovido) <r.koch@ovido.at>
Hi,
Has anyone an idea what's the easiest way to sysprep Linux (CentOS 6 and RHEL 6) machines?
The use case is the following: I want to create a lot of virtual machines (e.g. 100) by cloning from one template. So I create a master vm, create a template and a pool with 100 vms assigned to it and set all 100 vms to prestarted.
The problem is now, that when I run "sys-unconfig" before creating the template, which does a "touch /.unconfigured" I have to go through the sysconfig-tui and set a new root password for all 100 hosts.
So what I'm looking for is a script like the sysprep tool for windows which sets parameters for me automatically. I only need to change: * Hostname + set DHCP_HOSTNAME in ifcfg-eth0 (Hostname == Pool-VM-Name) for some dhcp/ddns magic :) * Clear udev network-rules * remove SSH-Keys * Remove RHN ID and join Satellite/Spacewalk-server * root-password,... should stay the same
My first question is: does oVirt provide such a functionality for Linux guest out-of-the-box? I couldn't find one.
I think I could solve this with virt-sysprep and virt-file, but I'm unsure if I can use it with oVirt (or only with plain libvirt): http://libguestfs.org/virt-sysprep.1.html http://libguestfs.org/virt-edit.1.html
For this tools it's required that the vm is not running, as it changes files on the disk. If I'm using a before-vm-start hook, it should be save to access the disk and change content with virt-sysprep/virt-file, right? But do I have access to the disk in a before-vm-start hook? If using NFS storage I should be able to access all disks on the NFS-share, but for iSCSI/FC-LUNS - are they available on the hypervisor in this stage?
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami :) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....
Thanks a lot for suggestions, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

http://libguestfs.org/virt-sysprep.1.html http://linux.die.net/man/1/virt-sysprep On 19 August 2013 18:12, Louis Coilliot <louis.coilliot@think.fr> wrote:
I DO this, sorry.
2013/8/19 Louis Coilliot <louis.coilliot@think.fr>
Hello,
I usually does this :
http://www.kermit.fr/lofic/snipper/20/
Regards,
Louis Coilliot
2013/8/19 René Koch (ovido) <r.koch@ovido.at>
Hi,
Has anyone an idea what's the easiest way to sysprep Linux (CentOS 6 and RHEL 6) machines?
The use case is the following: I want to create a lot of virtual machines (e.g. 100) by cloning from one template. So I create a master vm, create a template and a pool with 100 vms assigned to it and set all 100 vms to prestarted.
The problem is now, that when I run "sys-unconfig" before creating the template, which does a "touch /.unconfigured" I have to go through the sysconfig-tui and set a new root password for all 100 hosts.
So what I'm looking for is a script like the sysprep tool for windows which sets parameters for me automatically. I only need to change: * Hostname + set DHCP_HOSTNAME in ifcfg-eth0 (Hostname == Pool-VM-Name) for some dhcp/ddns magic :) * Clear udev network-rules * remove SSH-Keys * Remove RHN ID and join Satellite/Spacewalk-server * root-password,... should stay the same
My first question is: does oVirt provide such a functionality for Linux guest out-of-the-box? I couldn't find one.
I think I could solve this with virt-sysprep and virt-file, but I'm unsure if I can use it with oVirt (or only with plain libvirt): http://libguestfs.org/virt-sysprep.1.html http://libguestfs.org/virt-edit.1.html
For this tools it's required that the vm is not running, as it changes files on the disk. If I'm using a before-vm-start hook, it should be save to access the disk and change content with virt-sysprep/virt-file, right? But do I have access to the disk in a before-vm-start hook? If using NFS storage I should be able to access all disks on the NFS-share, but for iSCSI/FC-LUNS - are they available on the hypervisor in this stage?
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami :) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....
Thanks a lot for suggestions, René
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On 08/19/2013 10:17 AM, René Koch (ovido) wrote:
Hi,
Has anyone an idea what's the easiest way to sysprep Linux (CentOS 6 and RHEL 6) machines?
The use case is the following: I want to create a lot of virtual machines (e.g. 100) by cloning from one template. So I create a master vm, create a template and a pool with 100 vms assigned to it and set all 100 vms to prestarted.
The problem is now, that when I run "sys-unconfig" before creating the template, which does a "touch /.unconfigured" I have to go through the sysconfig-tui and set a new root password for all 100 hosts.
So what I'm looking for is a script like the sysprep tool for windows which sets parameters for me automatically. I only need to change: * Hostname + set DHCP_HOSTNAME in ifcfg-eth0 (Hostname == Pool-VM-Name) for some dhcp/ddns magic :) * Clear udev network-rules * remove SSH-Keys * Remove RHN ID and join Satellite/Spacewalk-server * root-password,... should stay the same
My first question is: does oVirt provide such a functionality for Linux guest out-of-the-box? I couldn't find one.
I think I could solve this with virt-sysprep and virt-file, but I'm unsure if I can use it with oVirt (or only with plain libvirt): http://libguestfs.org/virt-sysprep.1.html http://libguestfs.org/virt-edit.1.html
For this tools it's required that the vm is not running, as it changes files on the disk. If I'm using a before-vm-start hook, it should be save to access the disk and change content with virt-sysprep/virt-file, right? But do I have access to the disk in a before-vm-start hook? If using NFS storage I should be able to access all disks on the NFS-share, but for iSCSI/FC-LUNS - are they available on the hypervisor in this stage?
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami :) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....
Thanks a lot for suggestions, René
Hi René, You may be able to accomplish at least some of what you want using Cloud-Init, some features of which we've integrated into oVirt [1]. It went in recently so may not be in whichever version you're running, but you can probably borrow some of the concepts to get the job done. Just a few ideas: - create a vm payload [2] and attach it to the VM which can hold your config info e.g. vm name, which a custom script could pick up. No need for the latest oVirt with this option. - create a Cloud-Init config disk yourself and attach it as a payload, and let Cloud-Init do the initialization. There are several formats; oVirt uses Config-Drive-v2. Example at [3]. Depending on the config disk format, you may need the latest oVirt/vdsm to assign a volume label to the vm payload. - use the latest oVirt and its Cloud-Init functionality; for fields not handled, attach a file and let a script handle it. HTH, Greg [1] http://www.ovirt.org/Features/Cloud-Init_Integration [2] http://www.ovirt.org/Features/VMPayload [3] http://docs.openstack.org/trunk/openstack-compute/admin/content/config-drive...

-----Original message-----
From:Greg Padgett <gpadgett@redhat.com> Sent: Monday 19th August 2013 21:16 To: René Koch <r.koch@ovido.at> Cc: ovirt-users <users@ovirt.org> Subject: Re: [Users] Linux sysprep
On 08/19/2013 10:17 AM, René Koch (ovido) wrote:
Hi,
Has anyone an idea what's the easiest way to sysprep Linux (CentOS 6 and RHEL 6) machines?
The use case is the following: I want to create a lot of virtual machines (e.g. 100) by cloning from one template. So I create a master vm, create a template and a pool with 100 vms assigned to it and set all 100 vms to prestarted.
The problem is now, that when I run "sys-unconfig" before creating the template, which does a "touch /.unconfigured" I have to go through the sysconfig-tui and set a new root password for all 100 hosts.
So what I'm looking for is a script like the sysprep tool for windows which sets parameters for me automatically. I only need to change: * Hostname + set DHCP_HOSTNAME in ifcfg-eth0 (Hostname == Pool-VM-Name) for some dhcp/ddns magic :) * Clear udev network-rules * remove SSH-Keys * Remove RHN ID and join Satellite/Spacewalk-server * root-password,... should stay the same
My first question is: does oVirt provide such a functionality for Linux guest out-of-the-box? I couldn't find one.
I think I could solve this with virt-sysprep and virt-file, but I'm unsure if I can use it with oVirt (or only with plain libvirt): http://libguestfs.org/virt-sysprep.1.html http://libguestfs.org/virt-edit.1.html
For this tools it's required that the vm is not running, as it changes files on the disk. If I'm using a before-vm-start hook, it should be save to access the disk and change content with virt-sysprep/virt-file, right? But do I have access to the disk in a before-vm-start hook? If using NFS storage I should be able to access all disks on the NFS-share, but for iSCSI/FC-LUNS - are they available on the hypervisor in this stage?
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami :) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....
Thanks a lot for suggestions, René
Hi René,
You may be able to accomplish at least some of what you want using Cloud-Init, some features of which we've integrated into oVirt [1]. It went in recently so may not be in whichever version you're running, but you can probably borrow some of the concepts to get the job done.
Thanks a lot for your answer - this definitely points me into the right way.
Just a few ideas: - create a vm payload [2] and attach it to the VM which can hold your config info e.g. vm name, which a custom script could pick up. No need for the latest oVirt with this option.
For some strange reason I totally missed the vm payload feature (and it seems to be introduced already in oVirt 3.1 according to the release notes). Can I attach a vm payload via webadmin portal of oVirt 3.2 (and if yes - how?) or only via REST-API? So if I understand this right, I would do the following: - use before_vm_start_hook which creates the payload and updates vm xml definition - add <payloads> with e.g. file name "unattended.txt" andcontent "hostname=pool-vm95" - have script started in host which mounts the floppy, reads the content of unattended.txt and do some magic
- create a Cloud-Init config disk yourself and attach it as a payload, and let Cloud-Init do the initialization. There are several formats; oVirt uses Config-Drive-v2. Example at [3]. Depending on the config disk format, you may need the latest oVirt/vdsm to assign a volume label to the vm payload. - use the latest oVirt and its Cloud-Init functionality; for fields not handled, attach a file and let a script handle it.
cloud-init sounds very interesting, but this requires oVirt 3.3, right? I'm running oVirt 3.2 at the moment. Regards, René
HTH, Greg
[1] http://www.ovirt.org/Features/Cloud-Init_Integration [2] http://www.ovirt.org/Features/VMPayload [3] http://docs.openstack.org/trunk/openstack-compute/admin/content/config-drive...

On 08/19/2013 04:26 PM, René Koch wrote:
-----Original message-----
From:Greg Padgett <gpadgett@redhat.com> Sent: Monday 19th August 2013 21:16 To: René Koch <r.koch@ovido.at> Cc: ovirt-users <users@ovirt.org> Subject: Re: [Users] Linux sysprep
On 08/19/2013 10:17 AM, René Koch (ovido) wrote:
Hi,
Has anyone an idea what's the easiest way to sysprep Linux (CentOS 6 and RHEL 6) machines?
The use case is the following: I want to create a lot of virtual machines (e.g. 100) by cloning from one template. So I create a master vm, create a template and a pool with 100 vms assigned to it and set all 100 vms to prestarted.
The problem is now, that when I run "sys-unconfig" before creating the template, which does a "touch /.unconfigured" I have to go through the sysconfig-tui and set a new root password for all 100 hosts.
So what I'm looking for is a script like the sysprep tool for windows which sets parameters for me automatically. I only need to change: * Hostname + set DHCP_HOSTNAME in ifcfg-eth0 (Hostname == Pool-VM-Name) for some dhcp/ddns magic :) * Clear udev network-rules * remove SSH-Keys * Remove RHN ID and join Satellite/Spacewalk-server * root-password,... should stay the same
My first question is: does oVirt provide such a functionality for Linux guest out-of-the-box? I couldn't find one.
I think I could solve this with virt-sysprep and virt-file, but I'm unsure if I can use it with oVirt (or only with plain libvirt): http://libguestfs.org/virt-sysprep.1.html http://libguestfs.org/virt-edit.1.html
For this tools it's required that the vm is not running, as it changes files on the disk. If I'm using a before-vm-start hook, it should be save to access the disk and change content with virt-sysprep/virt-file, right? But do I have access to the disk in a before-vm-start hook? If using NFS storage I should be able to access all disks on the NFS-share, but for iSCSI/FC-LUNS - are they available on the hypervisor in this stage?
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami :) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....
Thanks a lot for suggestions, René
Hi René,
You may be able to accomplish at least some of what you want using Cloud-Init, some features of which we've integrated into oVirt [1]. It went in recently so may not be in whichever version you're running, but you can probably borrow some of the concepts to get the job done.
Thanks a lot for your answer - this definitely points me into the right way.
Great, happy to help.
Just a few ideas: - create a vm payload [2] and attach it to the VM which can hold your config info e.g. vm name, which a custom script could pick up. No need for the latest oVirt with this option.
For some strange reason I totally missed the vm payload feature (and it seems to be introduced already in oVirt 3.1 according to the release notes). Can I attach a vm payload via webadmin portal of oVirt 3.2 (and if yes - how?) or only via REST-API?
So if I understand this right, I would do the following: - use before_vm_start_hook which creates the payload and updates vm xml definition - add <payloads> with e.g. file name "unattended.txt" andcontent "hostname=pool-vm95" - have script started in host which mounts the floppy, reads the content of unattended.txt and do some magic
Only REST API. It sounds like you're on the right track with it.
- create a Cloud-Init config disk yourself and attach it as a payload, and let Cloud-Init do the initialization. There are several formats; oVirt uses Config-Drive-v2. Example at [3]. Depending on the config disk format, you may need the latest oVirt/vdsm to assign a volume label to the vm payload. - use the latest oVirt and its Cloud-Init functionality; for fields not handled, attach a file and let a script handle it.
cloud-init sounds very interesting, but this requires oVirt 3.3, right? I'm running oVirt 3.2 at the moment.
Yeah, 3.3 for the integrated features. You could use it standalone in 3.2, i.e. attach a config disk you made yourself--but compared to the approach above, the effort might not be worth it considering what you want to accomplish.
Regards, René
HTH, Greg
[1] http://www.ovirt.org/Features/Cloud-Init_Integration [2] http://www.ovirt.org/Features/VMPayload [3] http://docs.openstack.org/trunk/openstack-compute/admin/content/config-drive...

-- Mit freundlichen Grüßen DI (FH) René Koch Senior Solution Architect ============================================ ovido gmbh - "Das Linux Systemhaus" Brünner Straße 163, A-1210 Wien Phone: +43 720 / 530 670 - 0 Mobile: +43 660 / 512 21 31 E-Mail: r.koch@ovido.at ============================================ -----Original message-----
From:Greg Padgett <gpadgett@redhat.com> Sent: Monday 19th August 2013 22:55 To: René Koch <r.koch@ovido.at> Cc: ovirt-users <users@ovirt.org> Subject: Re: [Users] Linux sysprep
On 08/19/2013 04:26 PM, René Koch wrote:
-----Original message-----
From:Greg Padgett <gpadgett@redhat.com> Sent: Monday 19th August 2013 21:16 To: René Koch <r.koch@ovido.at> Cc: ovirt-users <users@ovirt.org> Subject: Re: [Users] Linux sysprep
On 08/19/2013 10:17 AM, René Koch (ovido) wrote:
Hi,
Has anyone an idea what's the easiest way to sysprep Linux (CentOS 6 and RHEL 6) machines?
The use case is the following: I want to create a lot of virtual machines (e.g. 100) by cloning from one template. So I create a master vm, create a template and a pool with 100 vms assigned to it and set all 100 vms to prestarted.
The problem is now, that when I run "sys-unconfig" before creating the template, which does a "touch /.unconfigured" I have to go through the sysconfig-tui and set a new root password for all 100 hosts.
So what I'm looking for is a script like the sysprep tool for windows which sets parameters for me automatically. I only need to change: * Hostname + set DHCP_HOSTNAME in ifcfg-eth0 (Hostname == Pool-VM-Name) for some dhcp/ddns magic :) * Clear udev network-rules * remove SSH-Keys * Remove RHN ID and join Satellite/Spacewalk-server * root-password,... should stay the same
My first question is: does oVirt provide such a functionality for Linux guest out-of-the-box? I couldn't find one.
I think I could solve this with virt-sysprep and virt-file, but I'm unsure if I can use it with oVirt (or only with plain libvirt): http://libguestfs.org/virt-sysprep.1.html http://libguestfs.org/virt-edit.1.html
For this tools it's required that the vm is not running, as it changes files on the disk. If I'm using a before-vm-start hook, it should be save to access the disk and change content with virt-sysprep/virt-file, right? But do I have access to the disk in a before-vm-start hook? If using NFS storage I should be able to access all disks on the NFS-share, but for iSCSI/FC-LUNS - are they available on the hypervisor in this stage?
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami :) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....
Thanks a lot for suggestions, René
Hi René,
You may be able to accomplish at least some of what you want using Cloud-Init, some features of which we've integrated into oVirt [1]. It went in recently so may not be in whichever version you're running, but you can probably borrow some of the concepts to get the job done.
Thanks a lot for your answer - this definitely points me into the right way.
Great, happy to help.
Just a few ideas: - create a vm payload [2] and attach it to the VM which can hold your config info e.g. vm name, which a custom script could pick up. No need for the latest oVirt with this option.
For some strange reason I totally missed the vm payload feature (and it seems to be introduced already in oVirt 3.1 according to the release notes). Can I attach a vm payload via webadmin portal of oVirt 3.2 (and if yes - how?) or only via REST-API?
So if I understand this right, I would do the following: - use before_vm_start_hook which creates the payload and updates vm xml definition - add <payloads> with e.g. file name "unattended.txt" andcontent "hostname=pool-vm95" - have script started in host which mounts the floppy, reads the content of unattended.txt and do some magic
Only REST API. It sounds like you're on the right track with it.
Thanks, I'll give it a try. Will post scripts if I managed to get it working in cause someone else can find it useful. Regards, René
- create a Cloud-Init config disk yourself and attach it as a payload, and let Cloud-Init do the initialization. There are several formats; oVirt uses Config-Drive-v2. Example at [3]. Depending on the config disk format, you may need the latest oVirt/vdsm to assign a volume label to the vm payload. - use the latest oVirt and its Cloud-Init functionality; for fields not handled, attach a file and let a script handle it.
cloud-init sounds very interesting, but this requires oVirt 3.3, right? I'm running oVirt 3.2 at the moment.
Yeah, 3.3 for the integrated features. You could use it standalone in 3.2, i.e. attach a config disk you made yourself--but compared to the approach above, the effort might not be worth it considering what you want to accomplish.
Regards, René
HTH, Greg
[1] http://www.ovirt.org/Features/Cloud-Init_Integration [2] http://www.ovirt.org/Features/VMPayload [3] http://docs.openstack.org/trunk/openstack-compute/admin/content/config-drive...

On Mon, 2013-08-19 at 16:54 -0400, Greg Padgett wrote:
On 08/19/2013 04:26 PM, René Koch wrote:
-----Original message-----
From:Greg Padgett <gpadgett@redhat.com> Sent: Monday 19th August 2013 21:16 To: René Koch <r.koch@ovido.at> Cc: ovirt-users <users@ovirt.org> Subject: Re: [Users] Linux sysprep
On 08/19/2013 10:17 AM, René Koch (ovido) wrote:
Hi,
Has anyone an idea what's the easiest way to sysprep Linux (CentOS 6 and RHEL 6) machines?
The use case is the following: I want to create a lot of virtual machines (e.g. 100) by cloning from one template. So I create a master vm, create a template and a pool with 100 vms assigned to it and set all 100 vms to prestarted.
The problem is now, that when I run "sys-unconfig" before creating the template, which does a "touch /.unconfigured" I have to go through the sysconfig-tui and set a new root password for all 100 hosts.
So what I'm looking for is a script like the sysprep tool for windows which sets parameters for me automatically. I only need to change: * Hostname + set DHCP_HOSTNAME in ifcfg-eth0 (Hostname == Pool-VM-Name) for some dhcp/ddns magic :) * Clear udev network-rules * remove SSH-Keys * Remove RHN ID and join Satellite/Spacewalk-server * root-password,... should stay the same
My first question is: does oVirt provide such a functionality for Linux guest out-of-the-box? I couldn't find one.
I think I could solve this with virt-sysprep and virt-file, but I'm unsure if I can use it with oVirt (or only with plain libvirt): http://libguestfs.org/virt-sysprep.1.html http://libguestfs.org/virt-edit.1.html
For this tools it's required that the vm is not running, as it changes files on the disk. If I'm using a before-vm-start hook, it should be save to access the disk and change content with virt-sysprep/virt-file, right? But do I have access to the disk in a before-vm-start hook? If using NFS storage I should be able to access all disks on the NFS-share, but for iSCSI/FC-LUNS - are they available on the hypervisor in this stage?
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami :) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....
Thanks a lot for suggestions, René
Hi René,
You may be able to accomplish at least some of what you want using Cloud-Init, some features of which we've integrated into oVirt [1]. It went in recently so may not be in whichever version you're running, but you can probably borrow some of the concepts to get the job done.
Thanks a lot for your answer - this definitely points me into the right way.
Great, happy to help.
Just a few ideas: - create a vm payload [2] and attach it to the VM which can hold your config info e.g. vm name, which a custom script could pick up. No need for the latest oVirt with this option.
For some strange reason I totally missed the vm payload feature (and it seems to be introduced already in oVirt 3.1 according to the release notes). Can I attach a vm payload via webadmin portal of oVirt 3.2 (and if yes - how?) or only via REST-API?
So if I understand this right, I would do the following: - use before_vm_start_hook which creates the payload and updates vm xml definition - add <payloads> with e.g. file name "unattended.txt" andcontent "hostname=pool-vm95" - have script started in host which mounts the floppy, reads the content of unattended.txt and do some magic
Only REST API. It sounds like you're on the right track with it.
I'm just playing around with the payload feature but I can't access the cd/floppy in my vm. I adapted Yuriy's script (http://lists.ovirt.org/pipermail/users/2013-June/014907.html - which is working fine btw) to create payload xml content and write it with hooking.write_domxml(domxml). In vdsm.log I can see that my python script exits with status code 0 and that the content seems to be added to the vm definition: Thread-130844::DEBUG::2013-08-21 12:43:52,669::libvirtvm::1520::vm.Vm::(_run) vmId=`79dc3123-4584-4dd9-b0f0-c28ede13d672`::<?xml version="1.0" encoding="utf-8"?><domain type="kvm"> <name>centos6</name> ....snip.... </cpu> <payloads><payload type="cdrom"><file name="unattended.txt"><content>hostname: centos6</content></file></payload></payloads></domain> But in my vm I can't mount the cd drive: # mount /dev/sr0 /media mount: you must specify the filesystem type Is there a special filesystem I have to specify? Furthermore shouldn't I be able to see the payloads content added to this vm via REST-API? Because I can't. Maybe I'm doing some wrong? Thanks, René
- create a Cloud-Init config disk yourself and attach it as a payload, and let Cloud-Init do the initialization. There are several formats; oVirt uses Config-Drive-v2. Example at [3]. Depending on the config disk format, you may need the latest oVirt/vdsm to assign a volume label to the vm payload. - use the latest oVirt and its Cloud-Init functionality; for fields not handled, attach a file and let a script handle it.
cloud-init sounds very interesting, but this requires oVirt 3.3, right? I'm running oVirt 3.2 at the moment.
Yeah, 3.3 for the integrated features. You could use it standalone in 3.2, i.e. attach a config disk you made yourself--but compared to the approach above, the effort might not be worth it considering what you want to accomplish.
Regards, René
HTH, Greg
[1] http://www.ovirt.org/Features/Cloud-Init_Integration [2] http://www.ovirt.org/Features/VMPayload [3] http://docs.openstack.org/trunk/openstack-compute/admin/content/config-drive...

On 08/21/2013 07:25 AM, René Koch (ovido) wrote: [snip]
I'm just playing around with the payload feature but I can't access the cd/floppy in my vm. I adapted Yuriy's script (http://lists.ovirt.org/pipermail/users/2013-June/014907.html - which is working fine btw) to create payload xml content and write it with hooking.write_domxml(domxml).
In vdsm.log I can see that my python script exits with status code 0 and that the content seems to be added to the vm definition:
Thread-130844::DEBUG::2013-08-21 12:43:52,669::libvirtvm::1520::vm.Vm::(_run) vmId=`79dc3123-4584-4dd9-b0f0-c28ede13d672`::<?xml version="1.0" encoding="utf-8"?><domain type="kvm"> <name>centos6</name> ....snip.... </cpu> <payloads><payload type="cdrom"><file name="unattended.txt"><content>hostname: centos6</content></file></payload></payloads></domain>
But in my vm I can't mount the cd drive: # mount /dev/sr0 /media mount: you must specify the filesystem type
Is there a special filesystem I have to specify?
Furthermore shouldn't I be able to see the payloads content added to this vm via REST-API? Because I can't.
Maybe I'm doing some wrong?
Thanks, René
That's a neat script. I haven't used it--instead I just send xml to the rest api, something like this, which looks a lot like yours: <vm id="6aec2d40-e36f-4b02-ab75-933d93f4cb8b" href="/api/vms/6aec2d40-e36f-4b02-ab75-933d93f4cb8b"> <payloads> <payload type="cdrom"> <file name="meta-data.txt"><content>some content</content> </file> </payload> </payloads> </vm> To attach the payload via the rest api, note that you'd need to send a put request to /api/vms/<uuid> rather than pass the xml in the run/start action, because that's not yet supported. Doing this, inside my vm I see: [root@cloud-init-test ~]# blkid /dev/sr1: UUID="2013-08-21-19-39-40-00" LABEL="CDROM" TYPE="iso9660" And I can mount it without any problems. You can also check the qemu process listing on the host--for instance, mine shows: /usr/bin/qemu-system-x86_64 [...] -drive file=/var/run/vdsm/payload/29e331f9-42df-46e1-aad1-88101b134606.fe53caf3339d55b2b37a893e19e9f10a.img While the vm is running, you can check that file with `file` (should report ISO 9660), mount it on the host, etc. HTH, Greg

On Wed, 2013-08-21 at 19:49 -0400, Greg Padgett wrote:
On 08/21/2013 07:25 AM, René Koch (ovido) wrote: [snip]
I'm just playing around with the payload feature but I can't access the cd/floppy in my vm. I adapted Yuriy's script (http://lists.ovirt.org/pipermail/users/2013-June/014907.html - which is working fine btw) to create payload xml content and write it with hooking.write_domxml(domxml).
In vdsm.log I can see that my python script exits with status code 0 and that the content seems to be added to the vm definition:
Thread-130844::DEBUG::2013-08-21 12:43:52,669::libvirtvm::1520::vm.Vm::(_run) vmId=`79dc3123-4584-4dd9-b0f0-c28ede13d672`::<?xml version="1.0" encoding="utf-8"?><domain type="kvm"> <name>centos6</name> ....snip.... </cpu> <payloads><payload type="cdrom"><file name="unattended.txt"><content>hostname: centos6</content></file></payload></payloads></domain>
But in my vm I can't mount the cd drive: # mount /dev/sr0 /media mount: you must specify the filesystem type
Is there a special filesystem I have to specify?
Furthermore shouldn't I be able to see the payloads content added to this vm via REST-API? Because I can't.
Maybe I'm doing some wrong?
Thanks, René
That's a neat script. I haven't used it--instead I just send xml to the rest api, something like this, which looks a lot like yours:
<vm id="6aec2d40-e36f-4b02-ab75-933d93f4cb8b" href="/api/vms/6aec2d40-e36f-4b02-ab75-933d93f4cb8b"> <payloads> <payload type="cdrom"> <file name="meta-data.txt"><content>some content</content> </file> </payload> </payloads> </vm>
To attach the payload via the rest api, note that you'd need to send a put request to /api/vms/<uuid> rather than pass the xml in the run/start action, because that's not yet supported. Doing this, inside my vm I see:
[root@cloud-init-test ~]# blkid /dev/sr1: UUID="2013-08-21-19-39-40-00" LABEL="CDROM" TYPE="iso9660"
I see - so only via REST-API really means only with REST-API ;) I'll add the payload via put request - thanks a lot!
And I can mount it without any problems. You can also check the qemu process listing on the host--for instance, mine shows:
/usr/bin/qemu-system-x86_64 [...] -drive file=/var/run/vdsm/payload/29e331f9-42df-46e1-aad1-88101b134606.fe53caf3339d55b2b37a893e19e9f10a.img
While the vm is running, you can check that file with `file` (should report ISO 9660), mount it on the host, etc.
HTH, Greg

On Thu, 2013-08-22 at 09:55 +0200, René Koch (ovido) wrote:
On Wed, 2013-08-21 at 19:49 -0400, Greg Padgett wrote:
On 08/21/2013 07:25 AM, René Koch (ovido) wrote: [snip]
I'm just playing around with the payload feature but I can't access the cd/floppy in my vm. I adapted Yuriy's script (http://lists.ovirt.org/pipermail/users/2013-June/014907.html - which is working fine btw) to create payload xml content and write it with hooking.write_domxml(domxml).
In vdsm.log I can see that my python script exits with status code 0 and that the content seems to be added to the vm definition:
Thread-130844::DEBUG::2013-08-21 12:43:52,669::libvirtvm::1520::vm.Vm::(_run) vmId=`79dc3123-4584-4dd9-b0f0-c28ede13d672`::<?xml version="1.0" encoding="utf-8"?><domain type="kvm"> <name>centos6</name> ....snip.... </cpu> <payloads><payload type="cdrom"><file name="unattended.txt"><content>hostname: centos6</content></file></payload></payloads></domain>
But in my vm I can't mount the cd drive: # mount /dev/sr0 /media mount: you must specify the filesystem type
Is there a special filesystem I have to specify?
Furthermore shouldn't I be able to see the payloads content added to this vm via REST-API? Because I can't.
Maybe I'm doing some wrong?
Thanks, René
That's a neat script. I haven't used it--instead I just send xml to the rest api, something like this, which looks a lot like yours:
<vm id="6aec2d40-e36f-4b02-ab75-933d93f4cb8b" href="/api/vms/6aec2d40-e36f-4b02-ab75-933d93f4cb8b"> <payloads> <payload type="cdrom"> <file name="meta-data.txt"><content>some content</content> </file> </payload> </payloads> </vm>
To attach the payload via the rest api, note that you'd need to send a put request to /api/vms/<uuid> rather than pass the xml in the run/start action, because that's not yet supported. Doing this, inside my vm I see:
[root@cloud-init-test ~]# blkid /dev/sr1: UUID="2013-08-21-19-39-40-00" LABEL="CDROM" TYPE="iso9660"
Hm, for some strange reason I can PUT the payloads XML to a specific vm without any errors using REST-API, but it seems to never really update the vm definition (when testing with GET payloads is missing again and no cd in my vm). PUT for e.g. usb definitions is working fine (system is oVirt 3.2). Anyway, I don't have enough time at the moment to investigate this further, so I use Yuriy's script (thanks!) and add the hostname via SKU number. But will maybe play with vm payloads later again. If anyone is interested in the scripts, feel free to use them: https://github.com/ovido/ovirt-stuff/tree/master/sysprep_linux (please note that these will only work for RHEL/CentOS/Fedora/other clones) Regards, René
And I can mount it without any problems. You can also check the qemu process listing on the host--for instance, mine shows:
/usr/bin/qemu-system-x86_64 [...] -drive file=/var/run/vdsm/payload/29e331f9-42df-46e1-aad1-88101b134606.fe53caf3339d55b2b37a893e19e9f10a.img
While the vm is running, you can check that file with `file` (should report ISO 9660), mount it on the host, etc.
HTH, Greg
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On 08/22/2013 10:19 AM, René Koch (ovido) wrote: ...
Hm, for some strange reason I can PUT the payloads XML to a specific vm without any errors using REST-API, but it seems to never really update the vm definition (when testing with GET payloads is missing again and no cd in my vm). PUT for e.g. usb definitions is working fine (system is oVirt 3.2).
Anyway, I don't have enough time at the moment to investigate this further, so I use Yuriy's script (thanks!) and add the hostname via SKU number. But will maybe play with vm payloads later again.
If anyone is interested in the scripts, feel free to use them: https://github.com/ovido/ovirt-stuff/tree/master/sysprep_linux (please note that these will only work for RHEL/CentOS/Fedora/other clones)
iirc, that's by design actually... since the payload may contain passwords for sysprep, etc... so do the PUT and check its there by launching the VM

On Thu, 2013-08-22 at 10:34 -0400, Itamar Heim wrote:
On 08/22/2013 10:19 AM, René Koch (ovido) wrote: ...
Hm, for some strange reason I can PUT the payloads XML to a specific vm without any errors using REST-API, but it seems to never really update the vm definition (when testing with GET payloads is missing again and no cd in my vm). PUT for e.g. usb definitions is working fine (system is oVirt 3.2).
Anyway, I don't have enough time at the moment to investigate this further, so I use Yuriy's script (thanks!) and add the hostname via SKU number. But will maybe play with vm payloads later again.
If anyone is interested in the scripts, feel free to use them: https://github.com/ovido/ovirt-stuff/tree/master/sysprep_linux (please note that these will only work for RHEL/CentOS/Fedora/other clones)
iirc, that's by design actually... since the payload may contain passwords for sysprep, etc... so do the PUT and check its there by launching the VM
Hm, this makes sense. I managed now to create a payload cd and can also access it from my vm as expected. Thanks all for your help, René

Although you've already got some answers with payload/cloudinit idea, I can point at another solution I've used myself: http://lists.ovirt.org/pipermail/users/2013-June/014907.html Use a vdsm-hook to write vmname into some bios field, then one-time init-script inside template to configure your vm as you need. Yuriy Demchenko On 08/19/2013 06:17 PM, René Koch (ovido) wrote:
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami:) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....

On Wed, 2013-08-21 at 13:18 +0400, Yuriy Demchenko wrote:
Although you've already got some answers with payload/cloudinit idea, I can point at another solution I've used myself: http://lists.ovirt.org/pipermail/users/2013-June/014907.html Use a vdsm-hook to write vmname into some bios field, then one-time init-script inside template to configure your vm as you need.
Thanks a lot, Yuriy. That's an interesting solution you came up with. Although I'm unsure if I like to use bios fields for this. Beside this "little bios hack" you're doing the same as with payloads except you're properly using dmidecode in your init-script to get the vm name instead of mounting a floppy and reading content of a file. Regards, René
Yuriy Demchenko
On 08/19/2013 06:17 PM, René Koch (ovido) wrote:
Another option would be to write a custom script which is started during boot and disables itself after successful run (in the same way as firstboot - I already have such a script for RHN Satellite/Spacewalk joins). The problem here is: How do I get the (oVirt) name of this vm (would need something like virt-whoami:) )? Is the (internal oVirt) ID of this vm stored somewhere in the filesystem of this vm? I don't think so....

Yea, that's right - i use dmidecode to get vmname in my init-script, I found it more convenient than reading some files. Besides, i've run into same problem as you with payload - it was added to domxml via hook, but somehow wasn't available inside VM. But i never did more troubleshooting of that problem, bios hack was enough for me. Yuriy Demchenko On 08/21/2013 01:32 PM, René Koch (ovido) wrote:
Thanks a lot, Yuriy. That's an interesting solution you came up with. Although I'm unsure if I like to use bios fields for this. Beside this "little bios hack" you're doing the same as with payloads except you're properly using dmidecode in your init-script to get the vm name instead of mounting a floppy and reading content of a file.
participants (7)
-
Ade
-
Greg Padgett
-
Itamar Heim
-
Louis Coilliot
-
René Koch
-
René Koch (ovido)
-
Yuriy Demchenko