main.yml 3.97 KB
Newer Older
Lars Beckers's avatar
Lars Beckers committed
1
2
3
4
---
# file: roles/nfs-client/tasks/main.yml

- name: ensure nfs client utils are installed
Robin Sonnabend's avatar
Robin Sonnabend committed
5
6
7
8
9
10
11
  apt:
    name:
      - nfs-common
      - libgssrpc4
      - librpcsecgss3
      - autofs
    state: present
Robin Sonnabend's avatar
Robin Sonnabend committed
12
13
14
15
  tags:
    - nfs-client
    - packages

16
- name: ensure cifs client utils are installed
Robin Sonnabend's avatar
Robin Sonnabend committed
17
18
19
20
21
  apt:
    name:
      - cifs-utils
      - smbclient
    state: present
22
23
24
25
26
27
  when: nfs_enable_cifs
  tags:
    - nfs-client
    - packages

- name: ensure quota tools are installed
28
  apt: name=quota state=present
29
30
31
32
33
  when: nfs_enable_quota
  tags:
    - nfs-client
    - packages

34
- name: ensure the nfs-client service is configured for nfs4
35
36
  copy: src=nfs-common dest=/etc/default/nfs-common owner=root group=root mode=0644
  notify:
37
    - restart nfs-client
38
39
40
41
42
    - restart autofs
  tags:
    - nfs-client
    - config

43
44
45
46
47
48
49
50
51
52
53
54
- name: ensure nfs module is loaded
  modprobe: name=nfs state=present
  tags:
    - nfs-client
    - config

- name: ensure nfs module is loaded after a reboot
  copy: content="nfs" dest=/etc/modules-load.d/nfs.conf
  tags:
    - nfs-client
    - config

55
- name: ensure we use the idmapper
56
  shell: echo "N" > /sys/module/nfs/parameters/nfs4_disable_idmapping
57
  notify:
58
    - restart nfs-client
59
60
61
62
63
64
65
66
67
68
    - 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
Robin Sonnabend's avatar
Robin Sonnabend committed
69

70
71
- 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
72
  when: debian_version == "jessie"
73
74
75
76
77
78
79
  notify:
    - reload sysctl
  tags:
    - nfs-client
    - sysctl
    - config

80
81
82
83
84
85
86
87
88
89
- name: stretch has a reasonable default value for the kernel key storage size
  sysctl: name=kernel.keys.root_maxkeys state=absent
  when: debian_version == "stretch"
  notify:
    - reload sysctl
  tags:
    - nfs-client
    - sysctl
    - config

90
- name: ensure nfs-common is enabled
91
  service: name=nfs-client.target state=started enabled=yes
92
93
94
95
  tags:
    - nfs-client
    - service

96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
- 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
        - 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:
        - restart autofs
      tags:
        - nfs-client
        - config

    - name: ensure automounter is enabled
123
      service: name=autofs state=started enabled=yes
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
      tags:
        - nfs-client
        - service

    - name: ensure linking of netdirs
      file: src="/net/{{ item.netdir }}" dest="/{{ item.dest }}" state=link force=yes
      with_items: "{{ nfs_shares }}"
      tags:
        - nfs-client

- name: Configure fstab nfs mounts
  when: not automount
  block:
    - name: Disable automounter
      service:
        name: autofs
        state: stopped
        enabled: no
      tags:
        - nfs-client
        - service

    - name: Ensure mountpoints are directories
      file:
        path: "/{{item.dest}}"
        state: directory
      with_items: "{{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
Lars Beckers's avatar
Lars Beckers committed
164

165
166
- name: configure default umask and other user related stuff
  copy: src=login.defs dest=/etc/login.defs owner=root group=root mode=0644
Lars Beckers's avatar
Lars Beckers committed
167
  tags:
Robin Sonnabend's avatar
Robin Sonnabend committed
168
    - nfs-client
169
170
    - umask
    - config
Lars Beckers's avatar
Lars Beckers committed
171

172
- meta: flush_handlers