diff --git a/roles/copr/hypervisor/tasks/main.yml b/roles/copr/hypervisor/tasks/main.yml index 6702453c7f..204de9c327 100644 --- a/roles/copr/hypervisor/tasks/main.yml +++ b/roles/copr/hypervisor/tasks/main.yml @@ -19,7 +19,7 @@ - libvirtd - config -- set_fact: image_pool_dir=/libvirt-images +- set_fact: image_pool_dir=/libvirt-images image_pool_name=images tags: libvirtd - name: create libvirt image directory @@ -68,6 +68,28 @@ notify: restart libvirtd tags: libvirtd +- name: check if image pool exists + shell: virsh pool-info "{{ image_pool_name }}" + register: libvirt_pool_exists + failed_when: false + changed_when: libvirt_pool_exists.rc != 0 + tags: libvirtd + +- name: copy image pool config file to host + template: src=libvirt-image-pool.xml + dest=/root/.tmp-ansible-file.xml + when: libvirt_pool_exists.changed + tags: libvirtd + +- name: define image pool in libvirt + shell: | + virsh pool-define /root/.tmp-ansible-file.xml + virsh pool-start "{{ image_pool_name }}" + virsh pool-autostart "{{ image_pool_name }}" + when: libvirt_pool_exists.changed + notify: restart libvirtd + tags: libvirtd + - name: allow copr user controlling libvirt ini_file: path: /usr/lib/systemd/system/libvirtd.socket diff --git a/roles/copr/hypervisor/templates/libvirt-pool-images.xml b/roles/copr/hypervisor/templates/libvirt-pool-images.xml new file mode 100644 index 0000000000..1c87d6b7a5 --- /dev/null +++ b/roles/copr/hypervisor/templates/libvirt-pool-images.xml @@ -0,0 +1,6 @@ + + {{ image_pool_name }} + + {{ image_pool_dir }} + +