From 17067eb872895b1cdaecb02776dce81d58a3c96c Mon Sep 17 00:00:00 2001 From: Lars Beckers <lars.beckers@rwth-aachen.de> Date: Sat, 13 May 2017 20:56:16 +0200 Subject: [PATCH] nfs-client: reworked role for kerberized nfs v4 --- nfs-client/files/create_netdir.sh | 8 --- nfs-client/files/modprobe-nfs.conf | 1 + nfs-client/handlers/main.yml | 3 -- nfs-client/tasks/main.yml | 83 ++++++++++++------------------ nfs-client/tasks/umask.yml | 15 ------ nfs-client/templates/auto.nfs.j2 | 6 +-- 6 files changed, 36 insertions(+), 80 deletions(-) delete mode 100644 nfs-client/files/create_netdir.sh create mode 100644 nfs-client/files/modprobe-nfs.conf delete mode 100644 nfs-client/tasks/umask.yml diff --git a/nfs-client/files/create_netdir.sh b/nfs-client/files/create_netdir.sh deleted file mode 100644 index b2f7552..0000000 --- a/nfs-client/files/create_netdir.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -if [ ! -h /$1 ]; then - rm /$1 - rmdir /$1 - ln -s /net/$1 /$1 -fi - diff --git a/nfs-client/files/modprobe-nfs.conf b/nfs-client/files/modprobe-nfs.conf new file mode 100644 index 0000000..2f7e4b4 --- /dev/null +++ b/nfs-client/files/modprobe-nfs.conf @@ -0,0 +1 @@ +options nfs nfs4_disable_idmapping=N diff --git a/nfs-client/handlers/main.yml b/nfs-client/handlers/main.yml index 6697abf..7944169 100644 --- a/nfs-client/handlers/main.yml +++ b/nfs-client/handlers/main.yml @@ -7,8 +7,5 @@ - name: restart nfs-common service: name=nfs-common state=restarted -- name: reload sysfs.conf - service: name=sysfsutils state=restarted - - name: reload sysctl command: sysctl -p diff --git a/nfs-client/tasks/main.yml b/nfs-client/tasks/main.yml index 9cd5804..7835528 100644 --- a/nfs-client/tasks/main.yml +++ b/nfs-client/tasks/main.yml @@ -2,42 +2,30 @@ # file: roles/nfs-client/tasks/main.yml - name: ensure nfs client utils are installed - apt: name=nfs-common state=latest - tags: - - nfs-client - - packages - -- name: ensure CIFS utils are installed - apt: name=cifs-utils,smbclient state=latest - tags: - - nfs-client - - cifs-client - - packages - -- name: ensure sysfs-utils are installed - apt: name=sysfsutils state=present + apt: name="{{ item }}" state=installed + with_items: + - nfs-common + - libgssrpc4 + - librpcsecgss3 + - autofs tags: - nfs-client - packages -- name: ensure we use the idmapper - command: 'echo "N" > /sys/module/nfs/parameters/nfs4_disable_idmapping' - notify: - - restart nfs-common - tags: - - nfs-client - - sysfs - - config - -- name: ensure we use the idmapper after a reboot - lineinfile: line="module/nfs/parameters/nfs4_disable_idmapping = N" dest=/etc/sysfs.conf create=yes - notify: - - reload sysfs.conf - - restart nfs-common - tags: - - nfs-client - - sysfs - - config +#- name: ensure we use the idmapper +# copy: content="N" dest=/sys/module/nfs/parameters/nfs4_disable_idmapping +# notify: +# - restart nfs-common +# - restart autofs +# tags: +# - nfs-client +# - config +# +#- 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 +# tags: +# - nfs-client +# - config - name: ensure the kernel key storage quote used for idmapping is sufficiently high sysctl: name=kernel.keys.root_maxkeys state=present value=1000 # default is 200, this quote was reached @@ -59,13 +47,12 @@ - sysctl - config -# makes life much easier to have an automounter and not /etc/fstab -- name: ensure automounter is installed - apt: name=autofs state=latest +- 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 - - autofs - - packages - name: ensure automounter is configured copy: src=auto.master dest=/etc/auto.master owner=root group=root mode=0644 @@ -73,39 +60,33 @@ - restart autofs tags: - nfs-client - - autofs - config - name: ensure mounts from central storage are available template: src=auto.nfs.j2 dest=/etc/auto.nfs owner=root group=root mode=0644 notify: - - nfs-client - restart autofs tags: - - autofs + - nfs-client - config - name: ensure automounter is enabled service: name=autofs state=running enabled=yes tags: - nfs-client - - autofs - service -- name: ensure linking of home - script: create_netdir.sh home +- name: ensure linking of netdirs + file: src="/net/{{ item.netdir }}" dest="/{{ item.dest }}" state=link force=yes + with_items: "{{ nfs_shares }}" tags: - nfs-client - - fsmpi - - autofs -- name: ensure linking of pub - script: create_netdir.sh pub +- name: configure default umask and other user related stuff + copy: src=login.defs dest=/etc/login.defs owner=root group=root mode=0644 tags: - nfs-client - - fsmpi - - autofs + - umask + - config - meta: flush_handlers -- include: umask.yml -- meta: flush_handlers diff --git a/nfs-client/tasks/umask.yml b/nfs-client/tasks/umask.yml deleted file mode 100644 index 6c9e2d4..0000000 --- a/nfs-client/tasks/umask.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -# file: roles/client/tasks/main.yml - -- name: configure default umask and other user related stuff - copy: src=login.defs dest=/etc/login.defs owner=root group=root mode=0644 - tags: - - umask - - config - -- name: activate pam.d session modules to set default umask - lineinfile: dest=/etc/pam.d/common-session line="session optional pam_umask.so" - tags: - - umask - - pam - - config diff --git a/nfs-client/templates/auto.nfs.j2 b/nfs-client/templates/auto.nfs.j2 index 11cc345..f60b42f 100644 --- a/nfs-client/templates/auto.nfs.j2 +++ b/nfs-client/templates/auto.nfs.j2 @@ -1,3 +1,3 @@ -{% for share in nfsshares %} -{{ share }} -{% endfor %} +{%- for share in nfs_shares %} +{{ share.netdir }} -{{ share.options }} {{ share.src }} +{% endfor -%} -- GitLab