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 - name: reload nfs
service: "name={{ nfs_server_daemon }} state=restarted" command: 'exportfs -ra'
when: nfs_exports|length

View file

@ -21,7 +21,6 @@
- name: Ensure directories to export exist - name: Ensure directories to export exist
file: 'path="{{ item.strip().split()[0] }}" state=directory' file: 'path="{{ item.strip().split()[0] }}" state=directory'
with_items: "{{ nfs_exports }}" with_items: "{{ nfs_exports }}"
notify: restart nfs
- name: Copy exports file. - name: Copy exports file.
template: template:
@ -30,12 +29,7 @@
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
register: nfs_exports_copy notify: reload nfs
notify: restart nfs
- name: Restart NFS immediately if exports are updated.
service: "name={{ nfs_server_daemon }} state=restarted"
when: nfs_exports_copy.changed
- name: Ensure nfs is running. - name: Ensure nfs is running.
service: "name={{ nfs_server_daemon }} state=started enabled=yes" service: "name={{ nfs_server_daemon }} state=started enabled=yes"