main.ymlΒΆ

---
- name: "πŸ“¦ Install the kernel NFS server"
  package_install: # nocheck: package-install only the kernel NFS flavor includes this file
    id:
      - nfs-client
      - nfs-kernel-server

- name: "πŸ“¦ Install the SELinux python binding (seboolean module + selinux fact)"
  package_install: # nocheck: package-install only the kernel NFS flavor includes this file
    id: selinux-python-binding

- name: "πŸ“Š Re-gather the SELinux fact now the binding is present"
  ansible.builtin.setup:
    gather_subset:
      - "!all"
      - selinux
  when: ansible_facts['os_family'] == 'RedHat'

- name: "πŸ“€ Allow kernel NFS to export read-write under SELinux (enforcing RedHat hosts)"
  ansible.posix.seboolean:
    name: nfs_export_all_rw
    state: true
    persistent: true
  when: ansible_facts.get('selinux', {}).get('status', 'disabled') == 'enabled'

- name: "πŸ“„ Render /etc/exports"
  ansible.builtin.template: # nocheck: stack-host-template (per-host NFS server /etc/exports (NFS host is its own group, not the stack host))
    src: exports.j2
    dest: /etc/exports
    owner: root
    group: root
    mode: "0644"
  notify: "reload-nfs-exports"

- name: "🚿 Flush handlers (exports reload before next step)"
  ansible.builtin.meta: flush_handlers

- name: "🟒 Enable and start the kernel NFS server"
  ansible.builtin.systemd:
    name: "{{ SVC_STORAGE_NFS_SERVER_SERVICE['kernel'][ansible_facts['os_family']] }}"
    enabled: true
    state: started