-
Notifications
You must be signed in to change notification settings - Fork 0
/
nfs_server.yaml
39 lines (31 loc) · 1.26 KB
/
nfs_server.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
- name: Installing NFS Server
hosts: nfsserver
become: true
vars:
mountable_share_drive: '/dev/sda1'
nfsexport: /share
src_exports: ~/templates/exports.j2
#nfsserver: hostvars[inventory_hostname]['facter_ipaddress_eth1'] #192.168.99.150
tasks:
- name: Create mountable dir
file: path={{ nfsexport }} state=directory mode=777 owner=root group=root
tags: nfs_server
- name: make sure the mount drive has a filesystem
filesystem: fstype=ext4 dev={{ mountable_share_drive | default('/dev/sda1') }}
tags: nfs_server
- name: set mountpoints
mount: name={{ nfsexport }} src={{ mountable_share_drive | default('/dev/sda1') }} fstype=auto opts=defaults,nobootwait dump=0 passno=2 state=mounted
tags: nfs_server
- name: Ensure NFS utilities are installed.
apt:
name: ['nfs-common','nfs-kernel-server']
state: present
update_cache: yes
tags: nfs_server
- name: copy /etc/exports
template: src={{ src_exports }} dest=/etc/exports owner=root group=root
tags: nfs_server
- name: restart nfs server
service: name=nfs-kernel-server state=restarted
tags: nfs_server