blob: 1d8488762a004cab7295ea88f6647867a4cb81d7 [file] [log] [blame]
Michal Zegan261023f2018-12-19 11:47:30 +01001---
2- name: Create nfs directory
3 file:
4 path: "{{ nfs_mount_path }}"
5 state: directory
6 mode: 0777
7
Milan Verespej09b5d952019-02-13 12:53:51 +01008- name: Install nfs packages
9 package:
10 name: "{{ item }}"
11 state: present
Samuli Silvius11ce2932019-03-23 13:54:34 +020012 loop: "{{ nfs_packages[ansible_os_family] }}"
Milan Verespej09b5d952019-02-13 12:53:51 +010013
Michal Zegan261023f2018-12-19 11:47:30 +010014- name: Setup nfs server
15 block:
16 - name: Start services
17 systemd:
18 name: "{{ item }}"
19 state: started
Samuli Silvius11ce2932019-03-23 13:54:34 +020020 enabled: true
21 loop: "{{ nfs_services[ansible_os_family] }}"
Michal Zegan261023f2018-12-19 11:47:30 +010022
23 - name: Add hosts to exports
24 template:
25 src: exports.j2
Michal Zegan1266d182019-04-09 15:21:52 +020026 dest: /etc/exports.d/dockerdata-nfs.exports
Samuli Silvius11ce2932019-03-23 13:54:34 +020027 notify:
28 - reload nfs
Michal Zegan261023f2018-12-19 11:47:30 +010029 when:
30 - "'nfs-server' in group_names"
31
Samuli Silvius11ce2932019-03-23 13:54:34 +020032- name: Force notified handlers to run at this point
33 meta: flush_handlers
34
Michal Zegan261023f2018-12-19 11:47:30 +010035- name: Mount dockerdata-nfs
36 mount:
37 path: "{{ nfs_mount_path }}"
Michal Zegan1266d182019-04-09 15:21:52 +020038 src: "{{ hostvars[groups['nfs-server'].0].cluster_ip }}:{{ nfs_mount_path }}"
Michal Zegan261023f2018-12-19 11:47:30 +010039 fstype: nfs
40 state: mounted
41 when:
42 - "'nfs-server' not in group_names"