-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1746f20
Showing
7 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
|
||
nfs_exported_directories: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
|
||
- name: refresh exports | ||
command: exportfs -ra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |