Initial commit

This commit is contained in:
moritzrfs
2025-05-05 19:59:39 +02:00
commit 0c06b42347
3 changed files with 72 additions and 0 deletions

56
nfs.yaml Normal file
View File

@@ -0,0 +1,56 @@
# nfs.yaml
- name: Setup NFS Server
hosts: nfs_servers
become: true
vars_files:
- vars.yaml
tasks:
- name: Install NFS server
apt:
name: nfs-kernel-server
state: present
- name: Create export directories
file:
path: "{{ item.path }}"
state: directory
loop: "{{ nfs_exports }}"
- name: Ensure NFS export entry is present (append only)
lineinfile:
path: /etc/exports
line: >-
{{ item.path }} {{ item.clients | map(attribute='name') | zip(item.clients | map(attribute='options')) | map('join', '(') | map('regex_replace', '$', ')') | join(' ') }}
create: yes
state: present
loop: "{{ nfs_exports }}"
- name: Reload NFS exports
command: exportfs -ra
- name: Setup NFS Client
hosts: nfs_clients
become: true
vars_files:
- vars.yaml
tasks:
- name: Install NFS client
apt:
name: nfs-common
state: present
- name: Create mount directories
file:
path: "{{ item.path }}"
state: directory
loop: "{{ nfs_mounts }}"
- name: Mount NFS shares
mount:
path: "{{ item.path }}"
src: "{{ item.src }}"
fstype: nfs
opts: rw
state: mounted
loop: "{{ nfs_mounts }}"