With the following task, and with the target drive not mounted:
- name: Disk is mounted
mount:
path: /media/external-drive
src: UUID={{ UUID }}
fstype: ext4
opts: "rw"
state: ephemeral
become: true
The playbook runs successfully the first time, and the drive is mounted. However, upon a second run I get the following error:
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Ephemeral mount point is already mounted with a different source than the specified one. Failing in order to prevent an unwanted unmount or override operation. Try replacing this command with a \"state: unmounted\" followed by a \"state: ephemeral\", or use a different destination path."}
I don't think the error's suggestion is appropriate because I do not wish to trigger a remount when one is already present. I would assume that ansible would recognize that a disk with the same UUID is already mounted on that destination path, and thus not do anything at all. I also specifically want to use the "ephemeral" option because I don't want to change the fstab file.
Run the aforementioned playbook with a sample UUID passed as argument
- name: Disk is mounted
mount:
path: /media/external-drive
src: UUID={{ UUID }}
fstype: ext4
opts: "rw"
state: ephemeral
become: true
EXPECTED RESULTS
I expected that running the playbook a second time around would output ok = 1 and changed = 0, because the mount point is already there
ACTUAL RESULTS
ok: [127.0.0.1]
TASK [Disk is mounted] ******************************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Ephemeral mount point is already mounted with a different source than the specified one. Failing in order to prevent an unwanted unmount or override operation. Try replacing this command with a \"state: unmounted\" followed by a \"state: ephemeral\", or use a different destination path."}
PLAY RECAP ******************************************************************************************************************************
127.0.0.1 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
SUMMARY
With the following task, and with the target drive not mounted:
The playbook runs successfully the first time, and the drive is mounted. However, upon a second run I get the following error:
I don't think the error's suggestion is appropriate because I do not wish to trigger a remount when one is already present. I would assume that ansible would recognize that a disk with the same UUID is already mounted on that destination path, and thus not do anything at all. I also specifically want to use the "ephemeral" option because I don't want to change the fstab file.
ISSUE TYPE
COMPONENT NAME
ansible.posix.mount
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
os: arch linux
STEPS TO REPRODUCE
Run the aforementioned playbook with a sample UUID passed as argument
EXPECTED RESULTS
I expected that running the playbook a second time around would output ok = 1 and changed = 0, because the mount point is already there
ACTUAL RESULTS