---
- name: install nfs server
  action: yum pkg=nfs-utils state=present

- name: install nfs client
  action: yum pkg=nfs-utils state=present

- name: ensure nfs service is running
  action: service name={{item}} state=started
  with_items:
    - rpcbind
    - nfslock
    - nfs

- include: "fdisk.yml"
  when:
    partition_nfs_share == True

- name: Ensure directories to export exist
  file: 'path="{{ item.strip().split()[0] }}" state=directory'
  with_items: "{{ nfs_exports }}"
  notify: restart nfs

- name: Copy exports file.
  template:
    src: exports.j2
    dest: /etc/exports
    owner: root
    group: root
    mode: 0644
  register: nfs_exports_copy
  notify: restart nfs

- name: Restart NFS immediately if exports are updated.
  service: name=nfs state=restarted
  when: nfs_exports_copy.changed


---
- name: install nfs server
  action: yum pkg=nfs-utils state=present

- name: install nfs client
  action: yum pkg=nfs-utils state=present

- name: ensure nfs service is running
  systemd:
    name: "{{item}}"
    state: started
    enabled: yes
  with_items:
    - rpcbind
    - nfslock
    - nfs

- include: "fdisk.yml"
  when:
    partition_nfs_share == True

- name: Ensure directories to export exist
  file: 'path="{{ item.strip().split()[0] }}" state=directory'
  with_items: "{{ nfs_exports }}"
  notify: restart nfs

- name: Copy exports file.
  template:
    src: exports.j2
    dest: /etc/exports
    owner: root
    group: root
    mode: 0644
  register: nfs_exports_copy
  notify: restart nfs

- name: Restart NFS immediately if exports are updated.
  service: name=nfs state=restarted
  when: nfs_exports_copy.changed


Fix nfs not enabled after reboot.
Fix nfs not enabled after reboot.
