Files
homelab-infra/infrastructure/proxmox/ansible/roles/nfs_mounts/tasks/main.yml
T
panxiao81 88a02ababa
lint / yaml (push) Has been cancelled
lint / ansible (push) Has been cancelled
lint / terraform (push) Has been cancelled
Establish clean homelab infrastructure baseline
Reorganize the brownfield repository, remove retired and generated artifacts, harden ignore rules, and record the GitOps/IaC redesign.
2026-09-09 16:47:20 +00:00

44 lines
1.1 KiB
YAML

---
- name: Install the NFS client
ansible.builtin.apt:
name: nfs-common
state: present
update_cache: true
cache_valid_time: 3600
register: _nfsc
retries: 3
delay: 15
until: _nfsc is succeeded
- name: Create the mount points
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: "0755"
loop: "{{ nfs_mounts }}"
loop_control:
label: "{{ item.path }}"
- name: Mount the NFS shares
ansible.posix.mount:
src: "{{ item.src }}"
path: "{{ item.path }}"
fstype: nfs
opts: "{{ item.opts | default(nfs_mounts_default_opts) }}"
state: "{{ item.state | default('mounted') }}"
loop: "{{ nfs_mounts }}"
loop_control:
label: "{{ item.src }} -> {{ item.path }}"
- name: Verify each share is actually readable
# `mount` reporting success is not proof: a stale handle or a squashed uid
# shows up only on the first read.
ansible.builtin.command:
cmd: "ls {{ item.path }}"
loop: "{{ nfs_mounts }}"
loop_control:
label: "{{ item.path }}"
register: _nfs_ls
changed_when: false
when: (item.state | default('mounted')) == 'mounted'