Skip to content

Commit

Permalink
Merge pull request #3 from radiorabe/feat/better-storage-pool-handling
Browse files Browse the repository at this point in the history
feat: better storabe pool creation handling
  • Loading branch information
smirta authored Jun 7, 2024
2 parents 3b7de63 + 12c8d9f commit 89de030
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion roles/libvirt/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,35 @@
enabled: true
name: "{{ libvirt_libvirt_service_name }}"

- name: Check if storage pool {{ libvirt_storage_pool_name }} already exists, do nothing if it does
command: virsh pool-info {{ libvirt_storage_pool_name }}
register: result
ignore_errors: true

- name: Write storage pool definition for {{ libvirt_storage_pool_name }}
template:
src: templates/storage-pool.xml.j2
dest: /tmp/storage-pool.xml
when: result.rc != 0

- name: Create storage pool {{ libvirt_storage_pool_name }}
command: virsh pool-create /tmp/storage-pool.xml
command: virsh pool-define /tmp/storage-pool.xml
when: result.rc != 0

- name: Create storage pool directory {{ libvirt_storage_pool_path }}
command: virsh pool-build {{ libvirt_storage_pool_name }}
when: result.rc != 0

- name: Set autostart in storage pool {{ libvirt_storage_pool_name }}
command: virsh pool-autostart {{ libvirt_storage_pool_name }}
when: result.rc != 0

- name: Start storage pool {{ libvirt_storage_pool_name }}
command: virsh pool-start {{ libvirt_storage_pool_name }}
when: result.rc != 0

- name: Remove storage pool definition /tmp/storage-pool.xml
file:
path: /tmp/storage-pool.xml
state: absent
when: result.rc != 0

0 comments on commit 89de030

Please sign in to comment.