The NFS API was designed to manage a mounts.yml file within nfs_mounts mounts puppet repo. This Python3 application is dockerized and posts to git using ssh keys embeded into the container.
main.py - flask application that defines the endpoints
mounts.py - the behind the scenes worker to read and update the mounts file
requirements.txt - pip3 install -r requirements.txt - will install the necesary packages needed to run the app
Acting as a container, the main purpose of this project is to managed a git based hiera defintion. Therefore, you must have a NFS Mounts project in git, that utilizes a hiera based defintion.
- Clone Project
- Modify git user profile configuration in dockerfile
- Run
docker build -t nfs_api:latest .
- Run
docker run \
-e REPO_URI=<full ssh git (ex. [email protected]:someuser/NFS-MOUNTS.git)> \
-v /path/to/ssh/on/host:/root/.ssh \
-e GIT_DIRECTORY=/path/to/store/repo
-p 5000:5000 \
nfs_api:latest
- Interact with the api on your servers ip address on port 80.
HTTP method | URI path | Description |
---|---|---|
GET | / | Returns health status to show node is active |
GET | /mounts | Retrieves all mounts |
GET | /mounts/hosts, /mounts/hostgroups | Retrieves just [hostname/hostgroup] mount. |
GET | /mounts/[hosts/hostgroups]/[servername/hostgroupname] | Retrieves servers/hostgroups mounts |
GET | /mounts/[hosts/hostgroups]/[servername/hostgroupname]/uuid | Retrieves invidiual mount point for given UUID |
POST/PUT | /mounts/[hosts/hostgroups] | Create new NAS Point for a particular host or hostgroup |
PATCH | /mounts/[hosts/hostgroups]/[servername/hostgroupname]/uuid | Modifies a NAS Point for a particular host or hostgroup |
DELETE | /mounts/[hosts/hostgroups]/[servername/hostgroupname] | Removes the management for a particular host or hostgroup |
DELETE | /mounts/[hosts/hostgroups]/[servername/hostgroupname]/uuid | Removes the management of a NAS Point for a particular host or hostgroup |
The structure of the hiera based yaml that defines an array of mount objects, located in the external REPO_SSH_URI (NFS-Mounts under a data directory), is as follows
nfs_mounts::Hosts:
Hostname.company.com:
- uuid
share_path
local_path
options
owner
group
Hostname2.company.com:
- ...
nfs_mounts::Hostgroups:
Group1:
- uuid
share_path
local_path
options
owner
group
- ...
Group2
...