diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..6c13055 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index 135f82a..81ea741 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..256ab35 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +nfs_exports: [] diff --git a/tasks/configure-Debian.yml b/tasks/configure-Debian.yml new file mode 100644 index 0000000..a5cc7be --- /dev/null +++ b/tasks/configure-Debian.yml @@ -0,0 +1,4 @@ +--- +- name: Ensure NFS is running. + service: name=nfs-kernel-server state=started enabled=yes + when: nfs_exports diff --git a/tasks/configure-RedHat.yml b/tasks/configure-RedHat.yml new file mode 100644 index 0000000..7ae72d3 --- /dev/null +++ b/tasks/configure-RedHat.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 066e8b3..5c7967e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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' diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 106d14e..0405359 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -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 diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index c4bf6e6..245ff03 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -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 diff --git a/templates/exports.j2 b/templates/exports.j2 new file mode 100644 index 0000000..fa27c55 --- /dev/null +++ b/templates/exports.j2 @@ -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 %} \ No newline at end of file