configure_libvirt_storage_pool.yml 993 B

123456789101112131415161718192021222324252627
  1. ---
  2. - name: Create libvirt storage directory for openshift
  3. file:
  4. dest: "{{ libvirt_storage_pool_path }}"
  5. state: directory
  6. # We need to set permissions on the directory and any items created under the directory, so we need to call the acl module with and without default set.
  7. - acl:
  8. default: "{{ item }}"
  9. entity: kvm
  10. etype: group
  11. name: "{{ libvirt_storage_pool_path }}"
  12. permissions: rwx
  13. state: present
  14. with_items:
  15. - no
  16. - yes
  17. - name: Test if libvirt storage pool for openshift already exists
  18. command: "virsh -c {{ libvirt_uri }} pool-info {{ libvirt_storage_pool }}"
  19. register: pool_info_result
  20. changed_when: False
  21. failed_when: "pool_info_result.rc != 0 and 'no storage pool with matching name' not in pool_info_result.stderr"
  22. - name: Create the libvirt storage pool for openshift
  23. command: 'virsh -c {{ libvirt_uri }} pool-create-as {{ libvirt_storage_pool }} dir --target {{ libvirt_storage_pool_path }}'
  24. when: pool_info_result.rc == 1