--- - name: Create the export directory trees block: - name: Create the directory of the NFS exports 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: Create the NFS exports folder file: dest: '/etc/exports.d' owner: root group: root state: directory mode: 0755 - name: Install the NFS export files template: src: 'kernel-nfs-exports.j2' dest: '/etc/exports.d/{{ item.name }}.exports' owner: root group: root mode: 0644 loop: '{{ nfs_server_exports }}' 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 -r when: update_exportfs is changed tags: ['san', 'nfs', 'storage', 'kernel_nfs', 'kernel_nfs_conf']