---
- name: setup firewall
  import_tasks: firewall.yml

- name: Install nfs-utils
  package:
    name: nfs-utils
    state: present
  register: result
  until: result is succeeded

- name: Configure NFS
  lineinfile:
    dest: /etc/sysconfig/nfs
    regexp: '^RPCNFSDARGS=.*$'
    line: 'RPCNFSDARGS="-N 2 -N 3"'
  register: nfs_config

- name: Restart nfs-config
  systemd: name=nfs-config state=restarted
  when: nfs_config is changed

- name: Ensure exports directory exists
  file:
    path: "{{ l_nfs_base_dir }}"
    state: directory

- name: Enable and start NFS services
  systemd:
    name: nfs-server
    state: started
    enabled: yes
