Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion roles/helper/fstab/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ansible.builtin.package:
name: "{{ (_common + _specific[ansible_os_family]) | select }}"
vars:
_common: []
_common: [util-linux]
_specific:
Debian:
- "{{ 'nfs-common' if ('nfs' in _fstypes) else None }}"
Expand All @@ -21,6 +21,30 @@
retries: 12
delay: 5

- name: Assert that fstab config matches existing filesystems
ansible.builtin.shell:
cmd: |
set -o errexit
FAILED=false
{% for v in _fstab %}
if TYPE="$(blkid -o value -s TYPE '{{ v.src }}')"; then
if [[ "$TYPE" != '{{ v.fstype | d('nfs') }}' ]]; then
echo "Filesystem type on device '{{ v.src }}' does not match requested fstab config ('$TYPE' != '{{ v.fstype | d('nfs') }}')." >&2
echo 'Please consider fixing this problem manually before continuing.' >&2
FAILED=true
fi
fi
{% endfor %}
if [[ "$FAILED" == true ]]; then
exit 1
fi
executable: /bin/bash
when: _fstab | count > 0
vars:
_fstab: >-
{{ fstab | d([]) | selectattr('src', 'defined') }}
changed_when: false

- name: Add to fstab and mount filesystems
ansible.posix.mount:
src: "{{ item.src }}"
Expand Down