# Hi - ansible with libvirt(kvm) hosts deployments

**URL:** <https://forum.ansible.com/t/hi-ansible-with-libvirt-kvm-hosts-deployments/28034>\
**Category:** Ansible Project\
**Created:** [July 12, 2018, 12:06pm UTC](https://forum.ansible.com/t/hi-ansible-with-libvirt-kvm-hosts-deployments/28034 "2018-07-12T12:06:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![francois\_P](https://avatars.discourse-cdn.com/v4/letter/f/b9bd4f/32.png) [@francois\_P](https://forum.ansible.com/u/francois_P)\
**Post date:** [July 12, 2018, 12:06pm UTC](https://forum.ansible.com/t/hi-ansible-with-libvirt-kvm-hosts-deployments/28034/1 "2018-07-12T12:06:40Z")

</div>

hello all,

I’m working with many virsh VM (libvirt), so ansible is very usefull to manage them & deploy applications & so on of course.

- Currently I use jinja2 template over xml to be able to import vm profile, this step is ok from shell (maybe it can be done from ansible ?but how ?)
- the I build the VM from shell , this step would be done from ansible ? (currently seems not possible)
- boot it with a kickstart or similar automatic installation of the OS. (currently seens not possible from ansible itself (not sure ansible has to be able to do that 🙂 )
- setup the machine after it boots up - this step is ok with ansible as soon as the ssh key are setup

I’m looking since a while how to do the same thing with ansible

The main goal of that is to be able to deploy end to end the vm skelton, the vm OS & of course the applications I need all from one main.yaml (whatever the number of roles will be defined).  
But here is what I’m looking for :  
----How to define a kvm virtual macine from X yaml file(s) – let’s concentrate on this step (more important to me)

thanks  
regards.

---

<div class="post-metadata">

**Author:** ![oxido\_A](https://avatars.discourse-cdn.com/v4/letter/o/7cd45c/32.png) [@oxido\_A](https://forum.ansible.com/u/oxido_A)\
**Post date:** [July 13, 2018, 12:27am UTC](https://forum.ansible.com/t/hi-ansible-with-libvirt-kvm-hosts-deployments/28034/2 "2018-07-13T00:27:33Z")

</div>

do you know about virsh ?

virsh create a32.xml??

Now, I’m not sure about if ansible has some kind of module ?

cheers!

XD

---

<div class="post-metadata">

**Author:** ![mhalano](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mhalano/32/1815_2.png) [@mhalano](https://forum.ansible.com/u/mhalano)\
**Post date:** [July 13, 2018, 1:54pm UTC](https://forum.ansible.com/t/hi-ansible-with-libvirt-kvm-hosts-deployments/28034/3 "2018-07-13T13:54:14Z")

</div>

You can try the module “virt” ([https://docs.ansible.com/ansible/devel/modules/virt\_module.html).This](https://docs.ansible.com/ansible/devel/modules/virt_module.html).This) module was made to manage VMs using libvirt.

---

<div class="post-metadata">

**Author:** ![francois\_P](https://avatars.discourse-cdn.com/v4/letter/f/b9bd4f/32.png) [@francois\_P](https://forum.ansible.com/u/francois_P)\
**Post date:** [July 13, 2018, 2:07pm UTC](https://forum.ansible.com/t/hi-ansible-with-libvirt-kvm-hosts-deployments/28034/4 "2018-07-13T14:07:12Z")

</div>

Thanks, I’m going to study & try it ; it seems to be the good solution for my needs 🙂 🙂
