Added NFS config playbooks
This commit is contained in:
parent
e5f8da5d83
commit
425ebbebcb
42
home_linux/install_nfs_client.yml
Normal file
42
home_linux/install_nfs_client.yml
Normal 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
|
||||||
|
|
||||||
|
|
||||||
29
home_linux/install_nfs_server.yml
Normal file
29
home_linux/install_nfs_server.yml
Normal 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
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user