infra/roles/nfs/tasks/nfs.yml

90 lines
1.7 KiB
YAML

---
- name: install nfs
apt:
name:
- nfs-common
- nfs-kernel-server
state: latest
update_cache: true
tags:
- packages
- name: template /etc/exports
template:
src: "{{ item }}.j2"
dest: /etc/{{ item }}
owner: root
group: root
with_items:
- nfs.conf
- exports
notify:
- call exportfs
- name: template configs
template:
src: "{{ item }}.j2"
dest: /etc/default/{{ item }}
owner: root
group: root
with_items:
- rpcbind
- nfs-kernel-server
notify:
- reload nfs-kernel-server
#- restart rpcbind
- name: load kernel module
modprobe:
name: nfsd
state: present
- name: enable nfs-kernel-server
service:
name: nfs-kernel-server
enabled: true
state: started
- name: mask rpcbind
service:
name: "{{ item }}"
masked: true
with_items:
- rpcbind.service
- rpcbind.socket
- name: template systemd mounts
template:
src: systemd-mount.j2
dest: "/etc/systemd/system/{{ systemd_name }}"
owner: root
group: root
mode: 0644
loop_control:
label: "{{ systemd_name }}"
vars:
systemd_name: "{{ item.where.split('/')[1:] | join('-') }}.mount"
when:
systemd_name != ".mount"
tags:
- nfs-mounts
with_items: "{{ deadspace_nfs_mounts[inventory_hostname] }}"
- name: start nfs mounts
service:
daemon_reload: true
name: "{{ systemd_name }}"
state: started
enabled: true
loop_control:
label: "{{ systemd_name }}"
vars:
systemd_name: "{{ item.where.split('/')[1:] | join('-') }}.mount"
when:
systemd_name != ".mount"
with_items: "{{ deadspace_nfs_mounts[inventory_hostname] }}"
tags:
- nfs-mounts