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 | |
| 8 | - name: Setup nfs server |
| 9 | block: |
| 10 | - name: Start services |
| 11 | systemd: |
| 12 | name: "{{ item }}" |
| 13 | state: started |
| 14 | with_items: "{{ nfs_services[ansible_os_family] }}" |
| 15 | |
| 16 | - name: Add hosts to exports |
| 17 | template: |
| 18 | src: exports.j2 |
| 19 | dest: /etc/exports |
| 20 | |
| 21 | - name: Export nfs |
| 22 | command: exportfs -ar |
| 23 | when: |
| 24 | - "'nfs-server' in group_names" |
| 25 | |
| 26 | - name: Mount dockerdata-nfs |
| 27 | mount: |
| 28 | path: "{{ nfs_mount_path }}" |
| 29 | src: "{{ hostvars[groups['nfs-server'].0].ansible_host }}:{{ nfs_mount_path }}" |
| 30 | fstype: nfs |
| 31 | state: mounted |
| 32 | when: |
| 33 | - "'nfs-server' not in group_names" |