2023-09-29 14:26:07 +02:00
|
|
|
---
|
2023-10-09 23:35:50 +02:00
|
|
|
- name: Install required packages
|
2023-09-29 14:26:07 +02:00
|
|
|
ansible.builtin.apt:
|
|
|
|
state: present
|
|
|
|
name:
|
|
|
|
- nfs-kernel-server
|
2023-10-09 21:20:51 +02:00
|
|
|
- nfs-common
|
2023-10-09 23:35:50 +02:00
|
|
|
- parted
|
|
|
|
|
|
|
|
- name: Create a new ext4 primary partition
|
|
|
|
community.general.parted:
|
|
|
|
device: "{{ nfs_host_storage_device }}"
|
|
|
|
number: 1
|
|
|
|
state: present
|
|
|
|
fs_type: ext4
|
2023-09-29 14:26:07 +02:00
|
|
|
|
2023-10-09 21:20:51 +02:00
|
|
|
- name: ensure nfs mountpoints exist
|
2023-09-29 14:26:07 +02:00
|
|
|
ansible.builtin.file:
|
2023-10-09 18:45:38 +02:00
|
|
|
path: "{{ item.directory }}"
|
2023-09-29 14:26:07 +02:00
|
|
|
state: directory
|
|
|
|
owner: nobody
|
|
|
|
group: nogroup
|
2023-10-09 22:28:29 +02:00
|
|
|
mode: '0777'
|
2023-10-09 21:23:32 +02:00
|
|
|
with_items: "{{ nfs_host_exports }}"
|
2023-09-29 09:38:36 +02:00
|
|
|
|
2023-10-09 23:35:50 +02:00
|
|
|
- name: Mount up device by label
|
|
|
|
ansible.posix.mount:
|
|
|
|
path: "{{ nfs_host_exports[0].directory }}"
|
|
|
|
src: /dev/sdb1
|
|
|
|
fstype: ext4
|
|
|
|
state: present
|
|
|
|
|
2023-10-09 18:45:38 +02:00
|
|
|
- name: template /etc/exports
|
2023-09-29 14:26:07 +02:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: templates/exports.j2
|
|
|
|
dest: "/etc/exports"
|
2023-10-09 21:20:51 +02:00
|
|
|
notify: reload nfs
|
|
|
|
|
|
|
|
- name: Ensure nfs is running.
|
2023-10-09 21:23:32 +02:00
|
|
|
ansible.builtin.service: "name=nfs-kernel-server state=started enabled=yes"
|
2023-10-09 21:20:51 +02:00
|
|
|
when: nfs_host_exports|length
|