Added NFS config playbooks

This commit is contained in:
VR 2023-02-01 15:55:44 +00:00
parent e5f8da5d83
commit 425ebbebcb
2 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,42 @@
---
- name: Setup access to NFS
hosts:
- zero
- docker
roles:
- common
become: yes
gather_facts: no
vars_prompt:
name: nfs_server
prompt: 'IP of NFS server: '
private: false
tasks:
- name: Install nfs-common
ansible.builtin.apt:
package:
- nfs-common
state: present
- name: Create directory for mount
ansible.builtin.file:
path: /mnt/seagate
state: directory
mode: '0777'
owner: root
group: root
- name: Add NFS server to fstab
ansible.builtin.lineinfile:
path: /etc/fstab
line: "{{ nfs_server }}:/mnt/seagate /mnt/seagate nfs rw 0 0"
register: result
- name: Reboot host to apply changes
ansible.builtin.reboot:
msg: "Reboot initiated by Ansible"
test_command: uptime
when: result is changed

View File

@ -0,0 +1,29 @@
---
- name: Install NFS server
hosts: nfs_servers
roles:
- common
become: yes
gather_facts: no
vars_prompt:
name: mount_dir
prompt: 'Name of mount directory: '
private: false
tasks:
- name: Install nfs-kernel-server
ansible.builtin.apt:
package:
- nfs-kernel-server
state: present
- name: Configure exports file
ansible.builtin.lineinfile:
path: /etc/exports
line: '/mnt/{{ mount_dir }} *(rw,no_root_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1000)'
state: present
- name: Start NFS server
ansible.builtin.command:
cmd: sudo exportfs -ra