---
- name: Create libvirt storage directory for openshift
  file:
    dest: "{{ libvirt_storage_pool_path }}"
    state: directory

# 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.
- acl:
    default: '{{ item.default }}'
    entity: kvm
    etype: group
    name: "{{ libvirt_storage_pool_path }}"
    permissions: '{{ item.permissions }}'
    state: present
  with_items:
    - default: no
      permissions: x
    - default: yes
      permissions: rwx

- name: Create the libvirt storage pool for OpenShift
  virt_pool:
    name: '{{ libvirt_storage_pool }}'
    state: '{{ item }}'
    autostart: 'yes'
    xml: "{{ lookup('template', 'storage-pool.xml') }}"
    uri: '{{ libvirt_uri }}'
  with_items:
    - present
    - active
