---
# TODO -- this may actually work on atomic hosts
- fail:
    msg: "openshift_storage_nfs_lvm is not compatible with atomic host"
  when: openshift_is_atomic | bool

- name: Create lvm volumes
  lvol: vg={{osnl_volume_group}} lv={{ item }} size={{osnl_volume_size}}G
  with_sequence: start={{osnl_volume_num_start}} count={{osnl_number_of_volumes}} format={{osnl_volume_prefix}}{{osnl_volume_size}}g%04d

- name: create filesystem
  filesystem: fstype=xfs dev=/dev/{{osnl_volume_group}}/{{ item }}
  with_sequence: start={{osnl_volume_num_start}} count={{osnl_number_of_volumes}} format={{osnl_volume_prefix}}{{osnl_volume_size}}g%04d

- name: mount volumes
  mount: name={{osnl_mount_dir}}/{{ item }} src=/dev/{{osnl_volume_group}}/{{ item }} state=mounted fstype=xfs passno=0
  with_sequence: start={{osnl_volume_num_start}} count={{osnl_number_of_volumes}} format={{osnl_volume_prefix}}{{osnl_volume_size}}g%04d

- name: Make mounts owned by nfsnobody
  file: path={{osnl_mount_dir}}/{{ item }} owner=nfsnobody group=nfsnobody mode=0700
  with_sequence: start={{osnl_volume_num_start}} count={{osnl_number_of_volumes}} format={{osnl_volume_prefix}}{{osnl_volume_size}}g%04d

- include_tasks: nfs.yml

- name: Create volume json file
  template: src=../templates/nfs.json.j2 dest=/root/persistent-volume.{{ item }}.json
  with_sequence: start={{osnl_volume_num_start}} count={{osnl_number_of_volumes}} format={{osnl_volume_prefix}}{{osnl_volume_size}}g%04d

# TODO - Get the json files to a master, and load them.
