ansible-role-basic-system-s.../tasks/ganesha-nfs.yml

105 lines
3.3 KiB
YAML

---
- name: ganesha-nfs | Create the export directory trees
block:
- name: ganesha-nfs | Create the directory of the NFS exports
ansible.builtin.file:
dest: "{{ item.path }}"
state: directory
owner: root
group: root
mode: "0755"
loop: "{{ nfs_server_ganesha_exports }}"
tags: [san, nfs, storage, ganesha, ganesha_export]
- name: ganesha-nfs | Repositories and packages on EL
block:
- name: ganesha-nfs | Install storage SIG repositories
ansible.builtin.yum:
name: "{{ nfs_server_ganesha_el_repos }}"
state: present
- name: ganesha-nfs | Install the SAN NFS packages
ansible.builtin.yum:
name: "{{ nfs_server_ganesha_el_pkgs }}"
state: present
- name: ganesha-nfs | Install the files needed to produce a SELinux policy for ganesha
ansible.builtin.copy:
src: "{{ item }}"
dest: /usr/local/lib/{{ item }}
owner: root
group: root
mode: "0600"
loop:
- ganesha_selinux.pp
- ganesha_selinux.te
register: ganesha_selinux_policy
- name: ganesha-nfs | Generate the SELinux policy module
ansible.builtin.shell: semodule -i /usr/local/lib/ganesha_selinux.pp && touch /usr/local/lib/.ganesha_selinux
when: ganesha_selinux_policy is changed # noqa: no-handler
changed_when: true
when: ansible_distribution_file_variety == "RedHat"
tags: [san, nfs, storage, ganesha, ganesha_pkg]
- name: ganesha-nfs | Repositories and packages on Ubuntu/Debian
block:
- name: ganesha-nfs | Install the nfs ganesha packages on deb systems
ansible.builtin.apt:
pkg: "{{ nfs_server_ganesha_deb_pkgs }}"
state: present
cache_valid_time: 1800
- name: ganesha-nfs | Ensure that the kernel NFS server package is not installed
ansible.builtin.apt:
pkg: nfs-kernel-server
state: absent
when: ansible_distribution_file_variety == "Debian"
tags: [san, nfs, storage, ganesha, ganesha_pkg]
- name: ganesha-nfs | Install and configure ganesha exports using the VFS backend
block:
- name: ganesha-nfs | Install the ganesha configuration files
ansible.builtin.template:
src: "{{ item }}.j2"
dest: /etc/ganesha/{{ item }}
owner: root
group: root
mode: "0644"
loop: "{{ nfs_ganesha_conf_files }}"
register: ganesha_conf_files
- name: ganesha-nfs | Install the ganesha export files
ansible.builtin.template:
src: ganesha-export.conf.j2
dest: /etc/ganesha/{{ item.name }}.conf
owner: root
group: root
mode: "0644"
loop: "{{ nfs_server_ganesha_exports }}"
register: ganesha_conf_files
- name: ganesha-nfs | Ensure that the Kernel NFS service is stopped on EL
ansible.builtin.service:
name: nfs-server
state: stopped
enabled: false
when: ansible_distribution_file_variety == "RedHat"
- name: ganesha-nfs | Ensure that ganesha is started and enabled
ansible.builtin.service:
name: nfs-ganesha
state: started
enabled: true
- name: ganesha-nfs | Reload ganesha after a reconfiguration
ansible.builtin.service:
name: nfs-ganesha
state: reloaded
when: ganesha_conf_files is changed # noqa: no-handler
tags: [san, nfs, storage, ganesha, ganesha_conf]