1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #1821 from leucos/path-expand-fix

Expands path on file operations
This commit is contained in:
Michael DeHaan 2013-01-07 05:05:20 -08:00
commit 03ab074d0d

View file

@ -265,6 +265,7 @@ class AnsibleModule(object):
return context return context
def user_and_group(self, filename): def user_and_group(self, filename):
filename = os.path.expanduser(filename)
st = os.stat(filename) st = os.stat(filename)
uid = st.st_uid uid = st.st_uid
gid = st.st_gid gid = st.st_gid
@ -309,6 +310,7 @@ class AnsibleModule(object):
return changed return changed
def set_owner_if_different(self, path, owner, changed): def set_owner_if_different(self, path, owner, changed):
path = os.path.expanduser(path)
if owner is None: if owner is None:
return changed return changed
user, group = self.user_and_group(path) user, group = self.user_and_group(path)
@ -325,6 +327,7 @@ class AnsibleModule(object):
return changed return changed
def set_group_if_different(self, path, group, changed): def set_group_if_different(self, path, group, changed):
path = os.path.expanduser(path)
if group is None: if group is None:
return changed return changed
old_user, old_group = self.user_and_group(path) old_user, old_group = self.user_and_group(path)
@ -341,6 +344,7 @@ class AnsibleModule(object):
return changed return changed
def set_mode_if_different(self, path, mode, changed): def set_mode_if_different(self, path, mode, changed):
path = os.path.expanduser(path)
if mode is None: if mode is None:
return changed return changed
try: try: