Use exportfs -ra instead of restarting the NFS service to avoid breaking already existing mounts

This commit is contained in:
Vincent Legoll 2018-04-24 14:54:10 +02:00
parent f2778aa96f
commit 8e7803392f
2 changed files with 3 additions and 10 deletions

View File

@ -1,4 +1,3 @@
---
- name: restart nfs
service: "name={{ nfs_server_daemon }} state=restarted"
when: nfs_exports|length
- name: reload nfs
command: 'exportfs -ra'

View File

@ -21,7 +21,6 @@
- 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:
@ -30,12 +29,7 @@
owner: root
group: root
mode: 0644
register: nfs_exports_copy
notify: restart nfs
- name: Restart NFS immediately if exports are updated.
service: "name={{ nfs_server_daemon }} state=restarted"
when: nfs_exports_copy.changed
notify: reload nfs
- name: Ensure nfs is running.
service: "name={{ nfs_server_daemon }} state=started enabled=yes"