Skip to content

while-true-do/ansible-role-srv_nfs

Repository files navigation

Github (tag) Github (license) Github (issues) Github (pull requests)

Travis (com)

Ansible (min. version) Ansible (platforms) Ansible (tags)

Ansible Role: srv_nfs

An Ansible Role to install and configure nfs.

Motivation

NFS is one of the standard tools and used in many environments.

Description

This role installs and configures nfs and nfs exports.

  • install nfs packages
  • start nfs services
  • take care of firewalld (optional)
  • create export directories
  • configure exports

Requirements

Used Modules:

Installation

Install from Ansible Galaxy

ansible-galaxy install while_true_do.srv_nfs

Install from Github

git clone https://github.com/while-true-do/ansible-role-srv_nfs.git while_true_do.srv_nfs

Usage

Role Variables

---
# defaults file for while_true_do.srv_nfs

## Package Management
# Defaults are based on Fedora
wtd_srv_nfs_package: "nfs-utils"
# State can be present|latest|absent
wtd_srv_nfs_package_state: "present"

### Everything below only applies to role=server.

## Configuration Management
wtd_srv_nfs_conf_exports: []
# - name: "testshare"           # will create /etc/exports.d/testshare.exports
#   path: "/testshare"          # will be created, if not existing
#   owner: "nobody"             # default: nobody
#   group: "nobody"             # default: nobody
#   mode: "0750"                # default: 0750
#   hosts:
#     - host: "192.168.0.1"
#       options: "rw,sync"      # default: sync
#     - host: "192.168.10.0/24"

## Service Management
wtd_srv_nfs_service: "nfs-server"
# State can be started|stopped
wtd_srv_nfs_service_state: "started"
wtd_srv_nfs_service_enabled: true

## Firewalld Management
wtd_srv_nfs_fw_mgmt: true
wtd_srv_nfs_fw_service: "nfs"
# State can be enabled|disabled
wtd_srv_nfs_fw_state: "enabled"
# Zone can be according to defined zones on your machine.
wtd_srv_nfs_fw_zone: "public"

Example Playbook

Running Ansible Roles can be done in a playbook.

Simple

---
- hosts: all
  roles:
    - role: while_true_do.srv_nfs

Advanced

- hosts: all
  roles:
  - role: while_true_do.srv_nfs
    wtd_srv_nfs_conf_exports:
      - name: "nfs"
        path: "/var/lib/nfs/"
        mode: 0755
        hosts:
          - host: "192.168.0.1"
          - host: "192.168.0.2"
     - name: "tftpboot"
       path: "/var/lib/tftpboot"
       owner: "root"
       group: "root"
       mode: 0755
       hosts:
         - hosts: "192.168.0.101"
           options: "rw,sync"
         - hosts: "192.168.0.102"

Known Issues

  1. RedHat Testing is currently not possible in public, due to limitations in subscriptions.
  2. Some services and features cannot be tested properly, due to limitations in docker.

Testing

Most of the "generic" tests are located in the Test Library.

Ansible specific testing is done with Molecule.

Infrastructure testing is done with testinfra.

Automated testing is done with Travis CI.

Contribute

Thank you so much for considering to contribute. We are very happy, when somebody is joining the hard work. Please fell free to open Bugs, Feature Requests or Pull Requests after reading the Contribution Guideline.

See who has contributed already in the kudos.txt.

License

This work is licensed under a BSD-3-Clause License.

Contact