Initial commit
This commit is contained in:
56
nfs.yaml
Normal file
56
nfs.yaml
Normal 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 }}"
|
||||
Reference in New Issue
Block a user