summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2021-03-08 05:52:54 -0500
committerGitHub <noreply@github.com>2021-03-08 04:52:54 -0600
commita1a57c699e8f60fead4a42f31725ff8746df332a (patch)
treea2bb07bc3acf1ea3a0728f0f73951312133b0b3d
parent65037d4781b028675f60a8f99704e6b1862987c1 (diff)
downloadansible-a1a57c699e8f60fead4a42f31725ff8746df332a.tar.gz
module_utils: ensure find_mount_point consistently returns text (#73625) (#73710)
(cherry picked from commit dabfee4d5c8ef445bdcb06a8b2ffe5327525a55d)
-rw-r--r--changelogs/fragments/fix_mount_point.yml2
-rw-r--r--lib/ansible/module_utils/basic.py12
2 files changed, 8 insertions, 6 deletions
diff --git a/changelogs/fragments/fix_mount_point.yml b/changelogs/fragments/fix_mount_point.yml
new file mode 100644
index 0000000000..755152cb77
--- /dev/null
+++ b/changelogs/fragments/fix_mount_point.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - ensure find_mount_point consistently returns text.
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py
index 33371b3cf3..333c587843 100644
--- a/lib/ansible/module_utils/basic.py
+++ b/lib/ansible/module_utils/basic.py
@@ -955,17 +955,17 @@ class AnsibleModule(object):
return (uid, gid)
def find_mount_point(self, path):
- path_is_bytes = False
- if isinstance(path, binary_type):
- path_is_bytes = True
+ '''
+ Takes a path and returns it's mount point
+
+ :param path: a string type with a filesystem path
+ :returns: the path to the mount point as a text type
+ '''
b_path = os.path.realpath(to_bytes(os.path.expanduser(os.path.expandvars(path)), errors='surrogate_or_strict'))
while not os.path.ismount(b_path):
b_path = os.path.dirname(b_path)
- if path_is_bytes:
- return b_path
-
return to_text(b_path, errors='surrogate_or_strict')
def is_special_selinux_path(self, path):