aboutsummaryrefslogtreecommitdiffstats
path: root/roles/nfsd/tasks/main.yml
blob: 7da92408a8694682875b99a9764793696c3c7752 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

# nfsd ~~ roles/nfsd/tasks/main.yml
# setup nfs daemon for a list of hosts

---

- debug:
    var: nfsd_dirs

- name: ensure nfsd required variables are set
  fail:
  when: item == "undefined"
  loop:
    - "{{ nfsd_dirs }}"

- name: ensure nfs shared group exists
  group:
    name: "{{ nfsd_group }}"
    gid: "{{ nfsd_group_id }}"
    system: true
    state: absent

- name: ensure nfs shared user exists
  user:
    name: "{{ nfsd_user }}"
    uid: "{{ nfsd_user_id }}"
    group: "{{ nfsd_group }}"
    system: true
    state: absent

- name: ensure nfsd directory exists
  file:
    path: "{{ nfsd_dir }}"
    owner: 0
    group: 0
    mode: 0700
    state: directory

- name: ensure directories exists
  file:
    path: "{{ nfsd_dir }}/{{ item }}"
    owner: 0
    group: 0
    mode: 0777
    state: directory
  loop: "{{ nfsd_dirs.split(' ') if nfsd_dirs is string else nfsd_dirs }}"

- name: generate /etc/exports configuration
  template:
    src: etc-exports.j2
    dest: /etc/exports
    owner: root
    mode: 0600

- name: include *BSD specific configuration
  include_tasks: "_{{ ansible_distribution | lower }}.yml"

- name: ensure required services are restarted and enabled
  service:
    name: "{{ item }}"
    state: restarted
    enabled: true
  loop:
    - mountd
    - nfsd
remember that computers suck.