Allow exports to be managed.

This commit is contained in:
Jeff Geerling 2014-11-12 15:02:07 -06:00
parent ac20f41190
commit 6f216a635f
9 changed files with 55 additions and 8 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -10,7 +10,11 @@ None.
## Role Variables
None.
Available variables are listed below, along with default values (see `defaults/main.yml`):
nfs_exports: []
A list of exports which will be placed in the `/etc/exports` file. See Ubuntu's simple [Network File System (NFS)](https://help.ubuntu.com/14.04/serverguide/network-file-system.html) guide for more info and examples. (Simple example: `nfs_exports: { "/home/public *(rw,sync,no_root_squash)" }`).
## Dependencies

2
defaults/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
nfs_exports: []

View File

@ -0,0 +1,4 @@
---
- name: Ensure NFS is running.
service: name=nfs-kernel-server state=started enabled=yes
when: nfs_exports

View File

@ -0,0 +1,7 @@
---
- name: Ensure rpcbind and nfs are running.
service: "name={{ item }} state=started enabled=yes"
with_items:
- rpcbind
- nfs
when: nfs_exports

View File

@ -5,3 +5,18 @@
- include: setup-Debian.yml
when: ansible_os_family == 'Debian'
- name: Copy exports file.
template:
src: exports.j2
dest: /etc/exports
owner: root
group: root
mode: 0644
# Configuration tasks.
- include: configure-RedHat.yml
when: ansible_os_family == 'RedHat'
- include: configure-Debian.yml
when: ansible_os_family == 'Debian'

View File

@ -5,5 +5,6 @@
- nfs-common
- nfs-kernel-server
- name: Ensure NFS is running.
service: name=nfs-kernel-server state=started enabled=yes
# This isn't necessary until exports are configured in /etc/exports.
# - name: Ensure NFS is running.
# service: name=nfs-kernel-server state=started enabled=yes

View File

@ -2,8 +2,9 @@
- name: Ensure NFS utilities are installed.
yum: name=nfs-utils state=installed
- name: Ensure rpcbind and nfs are running.
service: "name={{ item }} state=started enabled=yes"
with_items:
- rpcbind
- nfs
# This isn't necessary until exports are configured in /etc/exports.
# - name: Ensure rpcbind and nfs are running.
# service: "name={{ item }} state=started enabled=yes"
# with_items:
# - rpcbind
# - nfs

13
templates/exports.j2 Normal file
View File

@ -0,0 +1,13 @@
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
{% for export in nfs_exports %}
{{ export }}
{% endfor %}