copr-hv: auto-create libvirt image pool
This commit is contained in:
parent
8ebff52f89
commit
d5d57426d5
2 changed files with 29 additions and 1 deletions
|
@ -19,7 +19,7 @@
|
||||||
- libvirtd
|
- libvirtd
|
||||||
- config
|
- config
|
||||||
|
|
||||||
- set_fact: image_pool_dir=/libvirt-images
|
- set_fact: image_pool_dir=/libvirt-images image_pool_name=images
|
||||||
tags: libvirtd
|
tags: libvirtd
|
||||||
|
|
||||||
- name: create libvirt image directory
|
- name: create libvirt image directory
|
||||||
|
@ -68,6 +68,28 @@
|
||||||
notify: restart libvirtd
|
notify: restart libvirtd
|
||||||
tags: 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
|
- name: allow copr user controlling libvirt
|
||||||
ini_file:
|
ini_file:
|
||||||
path: /usr/lib/systemd/system/libvirtd.socket
|
path: /usr/lib/systemd/system/libvirtd.socket
|
||||||
|
|
6
roles/copr/hypervisor/templates/libvirt-pool-images.xml
Normal file
6
roles/copr/hypervisor/templates/libvirt-pool-images.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<pool type='dir'>
|
||||||
|
<name>{{ image_pool_name }}</name>
|
||||||
|
<target>
|
||||||
|
<path>{{ image_pool_dir }}</path>
|
||||||
|
</target>
|
||||||
|
</pool>
|
Loading…
Add table
Add a link
Reference in a new issue