ansible-role-basic-system-s.../tasks/nfs-kernel-server.yml

76 lines
2.0 KiB
YAML

---
- name: Create the export directory trees
block:
- name: Create the directory of the nextcloud NFS export
ansible.builtin.file:
dest: '{{ item.path }}'
state: directory
owner: root
group: root
mode: 0755
loop: '{{ nfs_server_exports }}'
tags: ['san', 'nfs', 'storage', 'kernel_nfs']
- name: Repositories and packages on EL
block:
- name: Install the NFS packages on EL
yum:
name: '{{ nfs_server_kernel_el_pkgs }}'
state: present
- name: Ensure that the Ganesha NFS server is not installed
yum:
name: nfs-ganesha
state: absent
when: ansible_distribution_file_variety == "RedHat"
tags: ['san', 'nfs', 'storage', 'kernel_nfs']
- name: Repositories and packages on Ubuntu/Debian
block:
- name: Install the nfs packages on deb systems
apt:
pkg: '{{ nfs_server_kernel_deb_pkgs }}'
state: present
cache_valid_time: 1800
- name: Ensure that the ganesha server package is not installed
apt:
pkg: nfs-ganesha
state: absent
when: ansible_distribution_file_variety == "Debian"
tags: ['san', 'nfs', 'storage', 'kernel_nfs']
- name: Manage the NFS exports
block:
- name: Install the NFS export file
template:
src: 'kernel-nfs-exports.j2'
dest: '/etc/exports'
owner: root
group: root
mode: 0644
register: update_exportfs
- name: Ensure that the Kernel NFS service is started and enabled on EL
service:
name: nfs-server
state: started
enabled: true
when: ansible_distribution_file_variety == "RedHat"
- name: Ensure that the Kernel NFS service is started and enabled on deb systems
service:
name: nfs-kernel-server
state: started
enabled: true
when: ansible_distribution_file_variety == "Debian"
- name: Refresh the exports
shell: exportfs -a
when: update_exportfs is changed
tags: ['san', 'nfs', 'storage', 'kernel_nfs', 'kernel_nfs_conf']