install guest OS using virt module

Dear all!

Does a kind soul have a pointer for me to a more detailed documentation
of the virt module or of handling libvirt VMs in general?

I can define a VM, I should be able to start/stop it. What I didn't
figure out yet is how to install the initial OS on the VM (from a
playbook, of course).

Cheers, Kai

You can run a kickstart or preseed installation, import disk-images or do various other things… For example see (an old version) of my provisioning config:

https://github.com/sigio/sigio-provisioning

These days I use something a bit different, which isn’t in a releasable form at this time.

You can run a kickstart or preseed installation, import disk-images or
do various other things... For example see (an old version) of my
provisioning config:

https://github.com/sigio/sigio-provisioning

Here is the one I use :
  https://github.com/toshywoshy/ansible-role-vminstaller
It is a role so you can import it into your structure.

I still need to push some updates and I have added support for Ubuntu, not yet in the repo, but it gives you a clear idea how to set it up.

Mark, Toshaan,

thanks for your answers.
So it's not possible using only the provided modules, you have to invoke
shell commands as well.
You both use a module "qemu-img" which doesn't seem to be provided with
ansible by default!?

Thanks & cheers, Kai

Kai,

Mark, Toshaan,

thanks for your answers.
So it's not possible using only the provided modules, you have to invoke
shell commands as well.

Well, it should be possible, with the virt module, run a install XML and then run the post install XML, then you would only use the template and the virt module, however since the virt-install module does this much better and I haven't figured a way how to write an acceptable and nice virt-install ansible module, I use a shell script

You both use a module "qemu-img" which doesn't seem to be provided with
ansible by default!?

Yes, this module was not accepted by Michael very long time ago.
I just created a PR, let's see if we can get it in now.
In the mean time if you require it, you can find it at :
https://raw.githubusercontent.com/toshywoshy/ansible-vm-install/master/playbooks/library/qemu-img , this is my old vm install playbook

Thanks & cheers, Kai

Regards,
Toshaan.