mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 03:00:23 -07:00
Merge pull request #517 from goozbach/devel
Updated the file module to handle the case where the UID for the file doesn't exist on the system.
This commit is contained in:
commit
9714f5c79d
1 changed files with 8 additions and 2 deletions
|
@ -184,8 +184,14 @@ def user_and_group(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
|
||||||
|
try:
|
||||||
user = pwd.getpwuid(uid)[0]
|
user = pwd.getpwuid(uid)[0]
|
||||||
|
except KeyError:
|
||||||
|
user = str(uid)
|
||||||
|
try:
|
||||||
group = grp.getgrgid(gid)[0]
|
group = grp.getgrgid(gid)[0]
|
||||||
|
except KeyError:
|
||||||
|
group = str(gid)
|
||||||
return (user, group)
|
return (user, group)
|
||||||
|
|
||||||
def set_context_if_different(path, context, changed):
|
def set_context_if_different(path, context, changed):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue