# 
# Install needed packages
#
- name: Install needed nfs server packages
  yum: pkg={{ item }} state=installed
  with_items: 
  - nfs-utils
  - rpcbind

- name: setup /etc/exports
  copy: src={{ ansible_fqdn }}-exports dest=/etc/exports
  tags: 
  - nfs/server   

- name: enable nfs-related services and run them (fedora)
  action: service name={{ item }}  enabled=true state=started
  with_items:
  - nfs-idmap
  - nfs-lock
  when: ansible_distribution == 'Fedora'

- name: enable nfs-related services and run them (rhel)
  action: service name={{ item }}  enabled=true state=started
  with_items:
  - rpcidmapd
  - rpcbind
  - nfs
  - nfslock
  when: ansible_distribution == 'RedHat'
