Michal Zegan | 261023f | 2018-12-19 11:47:30 +0100 | [diff] [blame] | 1 | --- |
| 2 | - name: Create nfs directory |
| 3 | file: |
| 4 | path: "{{ nfs_mount_path }}" |
| 5 | state: directory |
| 6 | mode: 0777 |
| 7 | |
Milan Verespej | 09b5d95 | 2019-02-13 12:53:51 +0100 | [diff] [blame] | 8 | - name: Install nfs packages |
| 9 | package: |
| 10 | name: "{{ item }}" |
| 11 | state: present |
Samuli Silvius | 11ce293 | 2019-03-23 13:54:34 +0200 | [diff] [blame^] | 12 | loop: "{{ nfs_packages[ansible_os_family] }}" |
Milan Verespej | 09b5d95 | 2019-02-13 12:53:51 +0100 | [diff] [blame] | 13 | |
Michal Zegan | 261023f | 2018-12-19 11:47:30 +0100 | [diff] [blame] | 14 | - name: Setup nfs server |
| 15 | block: |
| 16 | - name: Start services |
| 17 | systemd: |
| 18 | name: "{{ item }}" |
| 19 | state: started |
Samuli Silvius | 11ce293 | 2019-03-23 13:54:34 +0200 | [diff] [blame^] | 20 | enabled: true |
| 21 | loop: "{{ nfs_services[ansible_os_family] }}" |
Michal Zegan | 261023f | 2018-12-19 11:47:30 +0100 | [diff] [blame] | 22 | |
| 23 | - name: Add hosts to exports |
| 24 | template: |
| 25 | src: exports.j2 |
| 26 | dest: /etc/exports |
Samuli Silvius | 11ce293 | 2019-03-23 13:54:34 +0200 | [diff] [blame^] | 27 | notify: |
| 28 | - reload nfs |
Michal Zegan | 261023f | 2018-12-19 11:47:30 +0100 | [diff] [blame] | 29 | when: |
| 30 | - "'nfs-server' in group_names" |
| 31 | |
Samuli Silvius | 11ce293 | 2019-03-23 13:54:34 +0200 | [diff] [blame^] | 32 | - name: Force notified handlers to run at this point |
| 33 | meta: flush_handlers |
| 34 | |
Michal Zegan | 261023f | 2018-12-19 11:47:30 +0100 | [diff] [blame] | 35 | - name: Mount dockerdata-nfs |
| 36 | mount: |
| 37 | path: "{{ nfs_mount_path }}" |
Samuli Silvius | 11ce293 | 2019-03-23 13:54:34 +0200 | [diff] [blame^] | 38 | src: "{{ hostvars[groups['nfs-server'].0].ansible_host | default(hostvars[groups['nfs-server'].0].inventory_hostname) }}:{{ nfs_mount_path }}" |
Michal Zegan | 261023f | 2018-12-19 11:47:30 +0100 | [diff] [blame] | 39 | fstype: nfs |
| 40 | state: mounted |
| 41 | when: |
| 42 | - "'nfs-server' not in group_names" |