From 6b28bd80ed0a21314029a00d1162814cc02e0de5 Mon Sep 17 00:00:00 2001 From: Thomas Schneider <thomas@fsmpi.rwth-aachen.de> Date: Fri, 22 Nov 2024 18:04:37 +0100 Subject: [PATCH] =?UTF-8?q?nfs-client:=20Use=20systemd=E2=80=99s=20automou?= =?UTF-8?q?nt=20feature=20instead=20of=20autofs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nfs-client/tasks/main.yml | 160 +++++++++++--------------------------- 1 file changed, 47 insertions(+), 113 deletions(-) diff --git a/nfs-client/tasks/main.yml b/nfs-client/tasks/main.yml index de13684..fac584d 100644 --- a/nfs-client/tasks/main.yml +++ b/nfs-client/tasks/main.yml @@ -4,8 +4,6 @@ apt: name: - nfs-common - - libgssrpc4 - - autofs state: present tags: - nfs-client @@ -37,7 +35,6 @@ mode: '0644' notify: - restart nfs-client - - restart autofs tags: - nfs-client @@ -45,34 +42,8 @@ modprobe: name: nfs state: present - tags: - - nfs-client - -- name: ensure nfs module is loaded after a reboot - copy: - content: "nfs" - dest: /etc/modules-load.d/nfs.conf - tags: - - nfs-client - -- name: ensure we use the idmapper - copy: - content: "N" - dest: /sys/module/nfs/parameters/nfs4_disable_idmapping - unsafe_writes: true - notify: - - restart nfs-client - - restart autofs - tags: - - nfs-client - -- name: ensure we use the idmapper after a reboot - copy: - src: modprobe-nfs.conf - dest: /etc/modprobe.d/nfs.conf - owner: root - group: root - mode: '0644' + params: nfs4_disable_idmapping=N + persistent: present tags: - nfs-client @@ -91,92 +62,55 @@ tags: - nfs-client -- name: Configure automount - when: automount - block: - - name: ensure there is a base directory for automount - file: - state: directory - path: /net - owner: root - group: root - mode: '0755' - notify: - - restart autofs - tags: - - nfs-client - - - name: ensure automounter is configured - copy: - src: auto.master - dest: /etc/auto.master - owner: root - group: root - mode: '0644' - notify: - - restart autofs - tags: - - nfs-client - - - name: ensure mounts from central storage are available - template: - src: auto.nfs.j2 - dest: /etc/auto.nfs - owner: root - group: root - mode: '0644' - notify: - - restart autofs - tags: - - nfs-client - - - name: ensure automounter is enabled - service: - name: autofs - state: started - enabled: true - tags: - - nfs-client +- name: Disable and stop autofs + systemd: + name: autofs + state: stopped + enabled: false + ignore_errors: true + tags: + - nfs-client - - name: ensure linking of netdirs - file: - src: "/net/{{ item.netdir }}" - dest: "/{{ item.dest }}" - state: link - force: true - with_items: "{{ nfs_shares }}" - tags: - - nfs-client +- name: Remove old autofs directory + file: + path: /net + state: absent + tags: + - nfs-client -- name: Configure fstab nfs mounts - when: not automount - block: - - name: Disable automounter - service: - name: autofs - state: stopped - enabled: false - tags: - - nfs-client +- name: Ensure /home is a directory + file: + path: /home + state: directory + owner: root + group: root + mode: '0755' + tags: + - nfs-client - - name: Ensure mountpoints are directories - file: - path: "/{{ item.dest }}" - state: directory - with_items: "{{ nfs_shares }}" - tags: - - nfs-client +- name: Ensure mountpoints are directories + file: + path: "{{ item.dest }}" + state: directory + loop: "{{ nfs_shares }}" + tags: + - nfs-client - - name: Create fstab entries - mount: - fstype: "nfs" - src: "{{ item.src }}" - path: "/{{ item.dest }}" - opts: "{{ item.options }}" - state: mounted - with_items: "{{ nfs_shares }}" - tags: - - nfs-client +- name: Create fstab entries + mount: + fstype: "nfs" + src: "{{ item.src }}" + path: "{{ item.dest }}" + opts: "{{ item.options }}{{ maybe_automount }}" + state: mounted + loop: "{{ nfs_shares }}" + vars: + maybe_automount: >- + {% if automount -%} + ,x-systemd.automount + {%- endif %} + tags: + - nfs-client - name: configure default umask and other user related stuff copy: -- GitLab