63 lines
1.6 KiB
YAML
63 lines
1.6 KiB
YAML
---
|
|
- name: Setup NFS Storage for Nomad Cluster
|
|
hosts: nomad_cluster
|
|
become: yes
|
|
vars:
|
|
nfs_server: snail
|
|
nfs_export_path: /fs/1000/nfs/Fnsync
|
|
nfs_mount_path: /mnt/fnsync
|
|
nfs_options: "rw,sync,vers=4.2"
|
|
|
|
tasks:
|
|
- name: Install NFS client packages
|
|
package:
|
|
name: nfs-common
|
|
state: present
|
|
|
|
- name: Create NFS mount directory
|
|
file:
|
|
path: "{{ nfs_mount_path }}"
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
|
|
- name: Mount NFS share
|
|
mount:
|
|
path: "{{ nfs_mount_path }}"
|
|
src: "{{ nfs_server }}:{{ nfs_export_path }}"
|
|
fstype: nfs
|
|
opts: "{{ nfs_options }}"
|
|
state: mounted
|
|
|
|
- name: Ensure NFS mount persists after reboot
|
|
mount:
|
|
path: "{{ nfs_mount_path }}"
|
|
src: "{{ nfs_server }}:{{ nfs_export_path }}"
|
|
fstype: nfs
|
|
opts: "{{ nfs_options }}"
|
|
state: present
|
|
|
|
- name: Verify NFS mount
|
|
command: df -h "{{ nfs_mount_path }}"
|
|
register: mount_result
|
|
|
|
- name: Display mount result
|
|
debug:
|
|
var: mount_result.stdout
|
|
|
|
- name: Create Nomad data directories on NFS
|
|
file:
|
|
path: "{{ nfs_mount_path }}/nomad/{{ inventory_hostname }}"
|
|
state: directory
|
|
owner: nomad
|
|
group: nomad
|
|
mode: '0755'
|
|
|
|
- name: Create shared volumes directory
|
|
file:
|
|
path: "{{ nfs_mount_path }}/nomad/volumes"
|
|
state: directory
|
|
owner: nomad
|
|
group: nomad
|
|
mode: '0755' |