You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using state: absent to unmount a volume and remove it from /etc/fstab/, the module removes the fstab entry first and then unmounts the volume.
In the case of an error while unmounting (eg. Device busy), the fstab is not restored which puts the host in an improper state where a replay of the task/playbook will not unmount the volume since it's no longer present in /etc/fstab.
Mount a volume somewhere on the target host and add it to /etc/fstab
Do something to force the device in a busy state
Launch the playbook unmounting the volume
Notice the error
Launch the playbook a second time
Notice it now finishes without an error
Get the device out of its busy state
Launch the playbook a third time
Notice it still finishes without an error
The device is removed from fstab but still mounted
# Step 1:## On target host as root
VOLFILE=/path/to/volumefile # file to use as volume for this test
FSTYPE=ext2 # change with your choice of filesystem
DEVICE=$(losetup -f)
MOUNTPOINT=/mnt # set to an available mountpoint on host## Setup our test volume
dd if=/dev/zero bs=1M count=100 of="${VOLFILE}"
losetup "${DEVICE}""${VOLFILE}"
mkfs."${FSTYPE}""${DEVICE}"## Add it to /etc/fstabecho -e "${DEVICE}\t${MOUNTPOINT}\t${FSTYPE}\tdefaults\t0 0">> /etc/fstab
## Mount it (and validate fstab)
mount -a
# Step 2:## Make device busycd"${MOUNTPOINT}"## keep this shell open until step 7
sleep 3600
---
# Change values according to your setup
- name: mount cmvehost: target_hostbecome: truetasks:
- name: Unmount or test volumeansible.posix.mount:
path: /mntstate: absent
EXPECTED RESULTS
On failure, the entry in fstab should be preserved.
This could be accomplished either by adding it back after a failure or unmounting before editing fstab.
In the previously described test case, the first AND second run should fail and only the last should succeed, leaving us with both the fstab edited and the volume uunmounted.
ACTUAL RESULTS
After the first failure, /etc/fstab doesn't contain the volume anymore even though it's still mounted.
On the second run, no action is attempted since no matching entry is present in fstab. The same goes for the third run.
# Not relevant AFAIK
The text was updated successfully, but these errors were encountered:
JasonGantner
changed the title
state=absent failure to unmount does not revert fstab changes
mount: state=absent - failure to unmount does not revert fstab changes
Dec 13, 2024
SUMMARY
When using
state: absent
to unmount a volume and remove it from/etc/fstab/
, the module removes the fstab entry first and then unmounts the volume.In the case of an error while unmounting (eg.
Device busy
), the fstab is not restored which puts the host in an improper state where a replay of the task/playbook will not unmount the volume since it's no longer present in/etc/fstab
.ISSUE TYPE
COMPONENT NAME
mount
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Linux target hosts
STEPS TO REPRODUCE
EXPECTED RESULTS
On failure, the entry in fstab should be preserved.
This could be accomplished either by adding it back after a failure or unmounting before editing fstab.
In the previously described test case, the first AND second run should fail and only the last should succeed, leaving us with both the fstab edited and the volume uunmounted.
ACTUAL RESULTS
After the first failure,
/etc/fstab
doesn't contain the volume anymore even though it's still mounted.On the second run, no action is attempted since no matching entry is present in fstab. The same goes for the third run.
The text was updated successfully, but these errors were encountered: