summaryrefslogtreecommitdiffstats
path: root/ansible/roles/nfs/tasks/main.yml
blob: 1d8488762a004cab7295ea88f6647867a4cb81d7 (plain)
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
---
- name: Create nfs directory
  file:
    path: "{{ nfs_mount_path }}"
    state: directory
    mode: 0777

- name: Install nfs packages
  package:
    name: "{{ item }}"
    state: present
  loop: "{{ nfs_packages[ansible_os_family] }}"

- name: Setup nfs server
  block:
    - name: Start services
      systemd:
        name: "{{ item }}"
        state: started
        enabled: true
      loop: "{{ nfs_services[ansible_os_family] }}"

    - name: Add hosts to exports
      template:
        src: exports.j2
        dest: /etc/exports.d/dockerdata-nfs.exports
      notify:
        - reload nfs
  when:
    - "'nfs-server' in group_names"

- name: Force notified handlers to run at this point
  meta: flush_handlers

- name: Mount dockerdata-nfs
  mount:
    path: "{{ nfs_mount_path }}"
    src: "{{ hostvars[groups['nfs-server'].0].cluster_ip }}:{{ nfs_mount_path }}"
    fstype: nfs
    state: mounted
  when:
    - "'nfs-server' not in group_names"