- never run mkfs for nfs/nfs4/cifs entries (the filesystem task would try to format the share) - install nfs-common when an nfs mount is configured Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
980 B
YAML
Executable File
29 lines
980 B
YAML
Executable File
- name: install nfs client for network mounts
|
|
apt:
|
|
update_cache: yes
|
|
state: present
|
|
pkg: nfs-common
|
|
when: mount_points | selectattr('fstype', 'defined') | selectattr('fstype', 'in', ['nfs', 'nfs4']) | list | length > 0
|
|
|
|
- name: generate filesystem on mounts if not defined
|
|
filesystem:
|
|
fstype: "{{ mnt.fstype | default('ext4') }}"
|
|
dev: "{{ mnt.dev }}"
|
|
loop: "{{ mount_points }}"
|
|
loop_control:
|
|
loop_var: mnt
|
|
label: "{{ mnt.dev }}: {{ mnt.fstype | default('ext4') }}"
|
|
# network shares already have a filesystem; never format them
|
|
when: mnt.fstype | default('ext4') not in ['nfs', 'nfs4', 'cifs']
|
|
|
|
- name: mount required points
|
|
mount:
|
|
path: "{{ mnt.path }}"
|
|
src: "{{ mnt.dev }}"
|
|
state: "{{ mnt.state | default('mounted') }}"
|
|
fstype: "{{ mnt.fstype | default('ext4') }}"
|
|
opts: "{{ mnt.opts | default('defaults') }}"
|
|
loop: "{{ mount_points }}"
|
|
loop_control:
|
|
loop_var: mnt
|
|
label: "{{ mnt.dev }}: {{ mnt.path }}" |