j1ngk3.nfs
Ansible Role: NFS
This role installs the NFS (Network File System) server and client.
Requirements
There are no specific requirements.
Role Variables
Here are the variables you can use with this role, along with simple explanations:
# NFS mode: either server or client
nfs_mode: server
# Entry to be added to the /etc/exports file for sharing directories
nfs_exports:
- path: "/home"
export: "vnode*.localdomain(fsid=0,rw,async,no_root_squash,no_subtree_check,insecure)"
# Entry to be added to the /etc/fstab file for the NFS client
nfs_client_imports:
- local: "/home" # Local path
remote: "/home" # Remote path on the server
server_host: "{{hostvars['server']['ansible_default_ipv4']}}" # Server's IP address
If you are using NFS client imports, you can also define these extra options:
state
: More info at Ansible Mount Module.opts
: Learn more at Debian Fstab Wiki.dump
: Refer to Debian Fstab Wiki for details.passno
: Check Debian Fstab Wiki for information.
Dependencies
There are no dependencies.
Example Playbook
Here’s an example of how to set up an NFS server and a client:
- hosts: server
roles:
- { role: 'j1ngk3.nfs', nfs_mode: 'server', nfs_exports: [{path: "/home", export: "vnode*.localdomain(fsid=0,rw,async,no_root_squash,no_subtree_check,insecure)"}] }
- hosts: client
roles:
- { role: 'j1ngk3.nfs', nfs_mode: 'client', nfs_client_imports: [{ local: "/home", remote: "/home", server_host: "{{hostvars['server']['ansible_default_ipv4']}}" }] }
License
This project is licensed under the Apache License v2. You can read more about it here.