---
# Makes a new NFS export
#
# Include signature
#
# import_role:
#   role: openshift_nfs
#   tasks_from: create_export
# vars:
#   l_nfs_base_dir: Base dir to exports
#   l_nfs_export_config: Name to prefix the .exports file with
#   l_nfs_export_name: Name of sub-directory of the export
#   l_nfs_options: Mount Options

- name: "Ensure {{ l_nfs_export_name }} NFS export directory exists"
  file:
    path: "{{ l_nfs_base_dir }}/{{ l_nfs_export_name }}"
    state: directory
    mode: 0777
    owner: nfsnobody
    group: nfsnobody

- name: "Create {{ l_nfs_export_name }} NFS export"
  lineinfile:
    path: "/etc/exports.d/{{ l_nfs_export_config }}.exports"
    create: true
    state: present
    line: "{{ l_nfs_base_dir }}/{{ l_nfs_export_name }} {{ l_nfs_options }}"
  register: created_export

- name: Re-export NFS filesystems
  command: exportfs -ar
  when:
    - created_export is changed
