Installs nfs-common and manages NFS mount entries from nfs_client_mounts (src, path, optional opts, state present or absent). Each mount point is created without owner, group or mode, because once a share is mounted a chown or chmod there changes the permissions on the NFS server. The role writes only the fstab line and reloads systemd; it never mounts or unmounts. An absent entry maps to ansible.posix.mount's absent_from_fstab, which removes the line and leaves the share and the directory alone. The default options are _netdev,nofail. x-systemd.automount is left out. Verified locally: yamllint, ansible-lint (production profile), syntax check of the scenario playbooks, the controller-side refusals of verify.yml (14 cases, each matched on its own message), and the module's fstab behaviour against a scratch fstab (replacement, absent_from_fstab, idempotence). Not verified: Molecule, which runs only in CI; the apt install and the daemon-reload handler; that systemd generates the mount units in the scenario's containers. Refs #402 Assisted-by: Claude Code
76 lines
2.4 KiB
YAML
76 lines
2.4 KiB
YAML
---
|
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
|
# .gitea/workflows/molecule.yml. Needs the Ubuntu mirrors: the role installs nfs-common. The
|
|
# containers run systemd as PID 1 with a writable cgroup, so a daemon-reload builds mount units
|
|
# from /etc/fstab; no privileged mode. Nothing is ever mounted: the server below does not exist.
|
|
driver:
|
|
name: docker
|
|
platforms:
|
|
- name: ${KAMINO_RUN_ID:-local}-nfs-client-noble
|
|
labels:
|
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
|
image: ${MOLECULE_IMAGE}
|
|
pre_build_image: true
|
|
pull: true
|
|
command: /sbin/init
|
|
cgroupns_mode: host
|
|
volumes:
|
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
|
tmpfs:
|
|
- /run
|
|
- /run/lock
|
|
security_opts:
|
|
- apparmor=unconfined
|
|
- name: ${KAMINO_RUN_ID:-local}-nfs-client-resolute
|
|
labels:
|
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
|
image: ${MOLECULE_IMAGE_2604}
|
|
pre_build_image: true
|
|
pull: true
|
|
command: /sbin/init
|
|
cgroupns_mode: host
|
|
volumes:
|
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
|
tmpfs:
|
|
- /run
|
|
- /run/lock
|
|
security_opts:
|
|
- apparmor=unconfined
|
|
provisioner:
|
|
name: ansible
|
|
# One source for every play, so the converge and the plays in verify.yml start from the same
|
|
# valid input: a default-options mount, one with its own options, one to remove (prepare.yml
|
|
# seeds its line), and /mnt/data, whose seeded line has another server and must be replaced.
|
|
inventory:
|
|
group_vars:
|
|
all:
|
|
nfs_client_mounts:
|
|
- src: nas.example:/export/data
|
|
path: /mnt/data
|
|
- src: nas.example:/export/media
|
|
path: /mnt/media
|
|
opts: _netdev,nofail,ro,vers=4.2
|
|
- src: nas.example:/export/old
|
|
path: /mnt/old
|
|
state: absent
|
|
verifier:
|
|
name: ansible
|
|
scenario:
|
|
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
|
|
# containers as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
|
|
# plus a check before the converge (fresh host) and one after it (configured host).
|
|
test_sequence:
|
|
- dependency
|
|
- cleanup
|
|
- syntax
|
|
- create
|
|
- prepare
|
|
- check
|
|
- converge
|
|
- check
|
|
- idempotence
|
|
- side_effect
|
|
- verify
|
|
- cleanup
|