---
- fail:
    msg: "This role is not yet supported on atomic hosts"
  when: openshift.common.is_atomic | bool

- name: Install pyparted (RedHat/Fedora)
  action: "{{ ansible_pkg_mgr }} name=pyparted,python-httplib2 state=present"
  when: not openshift.common.is_containerized | bool

- name: partition the drives
  partitionpool: disks={{ disks }} force={{ force }} sizes={{ sizes }}

- name: create filesystem
  filesystem: fstype=ext4 dev=/dev/{{ item.name }}
  with_items: "{{ partition_pool }}"

- name: mount
  mount: name={{mount_dir}}/{{ item.name }} src=/dev/{{ item.name }} state=mounted fstype=ext4 passno=2
  with_items: "{{ partition_pool }}"

- include: nfs.yml

- name: export physical volumes
  uri:
    url: "{{ kubernetes_url }}/api/{{ kube_api_version }}/persistentvolumes"
    method: POST
    body: "{{ lookup('template', kube_req_template) }}"
    body_format: json
    status_code: 201
    HEADER_Authorization: "Bearer {{ kubernetes_token }}"
  with_items: "{{ partition_pool }}"
