Skip to content

Fix sanitize mount src before comparing to mount point for macOS #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kidylee
Copy link

@kidylee kidylee commented Apr 14, 2025

SUMMARY

The mount command mount_smbfs on macOS doesn't have a separated parameter for password, hence the src parameter attaches password like below:

- name: synology storage mount
  ansible.posix.mount:
    src: //{{SYNOLOGY_USERNAME}}:{{SYNOLOGY_PASSWORD}}@10.10.10.251/storage
    path: /Users/kidy/Synology/storage
    fstype: smbfs
    state: ephemeral

It occurs below error when it mounted on second run:

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.

The reason is it trying to compare
src: //{{SYNOLOGY_USERNAME}}:{{SYNOLOGY_PASSWORD}}@10.10.10.251/storage
to the mount point:
//{{SYNOLOGY_USERNAME}}@10.10.10.251/storage

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

mount

ADDITIONAL INFORMATION
# sanitize src
src = re.sub(r'(//[^:]+):([^@]+)@', r'\1@', src)

Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant