Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
atsaki committed Mar 22, 2014
0 parents commit 1746f20
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 0 deletions.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Role Name
========

This role installs and setup NFS server.

Requirements
------------

Ansible 1.4 or higher.

Role Variables
--------------

```yaml
nfs_exported_directories: []
```
Dependencies
------------
None.
Example Playbook
-------------------------
```yaml

- role: atsaki.nfs
nfs_exported_directories:
- path: /export/test1
hosts:
- {name: 192.168.0.0/16, options: ["ro", "sync"]}
- {name: 10.0.0.5, options: ["rw", "sync", "no_root_squash"]}
- path: /export/test2
hosts:
- {name: "*", options: []}
```
License
-------
BSD
Author Information
------------------
This role was created in 2014 by Atsushi Sasaki (@atsaki).
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

nfs_exported_directories: []
4 changes: 4 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---

- name: refresh exports
command: exportfs -ra
16 changes: 16 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
galaxy_info:
author: Atsushi Sasaki
description: NFS installation and setup
license: license (BSD)
min_ansible_version: 1.4
platforms:
- name: EL
versions:
- 6
- name: Ubuntu
versions:
- precise
categories:
- system
dependencies: []
32 changes: 32 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---

- name: Include OS specific variables
include_vars: "{{ ansible_os_family }}.yml"

- name: Install nfs-utils when ansible_os_family is RedHat
yum: name="{{ item }}" state=installed
with_items: nfs_packages
when: ansible_os_family == "RedHat"

- name: Install nfs-kernel-server when ansible_os_family is Debian
apt: name="{{ item }}" state=installed
with_items: nfs_packages
when: ansible_os_family == "Debian"

- name: Ensure NFS service started and enabled
service: name="{{ item }}" state=started enabled=yes
with_items: nfs_services

- name: Ensure exported directory exists
file: path="{{ item.path }}" state=directory
owner='{{ item.owner|default(nfs_default_owner) }}'
group='{{ item.group|default(nfs_default_group) }}'
mode='{{ item.mode|default("0777") }}'
with_items: nfs_exported_directories

- name: Ensure exported directories are in /etc/exports
lineinfile: dest=/etc/exports
regexp="^{{ item.path }}\s"
line='{{ item.path }} {% for host in item.hosts %} {{ host.name }}({{ host.options|default([])|join(",") }}){% endfor %}'
with_items: nfs_exported_directories
notify: refresh exports
10 changes: 10 additions & 0 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

nfs_packages:
- nfs-kernel-server

nfs_services:
- nfs-kernel-server

nfs_default_owner: nobody
nfs_default_group: nogroup
11 changes: 11 additions & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

nfs_packages:
- nfs-utils

nfs_services:
- rpcbind
- nfs

nfs_default_owner: nfsnobody
nfs_default_group: nfsnobody

0 comments on commit 1746f20

Please sign in to comment.