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 |
| 12 | with_items: "{{ nfs_packages[ansible_os_family] }}" |
| 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 |
| 20 | with_items: "{{ nfs_services[ansible_os_family] }}" |
| 21 | |
| 22 | - name: Add hosts to exports |
| 23 | template: |
| 24 | src: exports.j2 |
| 25 | dest: /etc/exports |
| 26 | |
| 27 | - name: Export nfs |
| 28 | command: exportfs -ar |
| 29 | when: |
| 30 | - "'nfs-server' in group_names" |
| 31 | |
| 32 | - name: Mount dockerdata-nfs |
| 33 | mount: |
| 34 | path: "{{ nfs_mount_path }}" |
| 35 | src: "{{ hostvars[groups['nfs-server'].0].ansible_host }}:{{ nfs_mount_path }}" |
| 36 | fstype: nfs |
| 37 | state: mounted |
| 38 | when: |
| 39 | - "'nfs-server' not in group_names" |