Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
36527ca9
Commit
36527ca9
authored
Aug 10, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #838 from sfromm/issue825
Update file module to not recurse when setting ownership
parents
a7415e54
94696fb8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
library/file
+14
-4
No files found.
library/file
View file @
36527ca9
...
...
@@ -161,8 +161,13 @@ def set_owner_if_different(path, owner, changed):
return
changed
user
,
group
=
user_and_group
(
path
)
if
owner
!=
user
:
rc
=
os
.
system
(
"/bin/chown -R
%
s
%
s 2>/dev/null"
%
(
owner
,
path
))
if
rc
!=
0
:
try
:
uid
=
pwd
.
getpwnam
(
owner
)
.
pw_uid
except
KeyError
:
module_fail_json
(
path
=
path
,
msg
=
'chown failed: failed to look up user
%
s'
%
owner
)
try
:
os
.
chown
(
path
,
uid
,
-
1
)
except
OSError
:
module_fail_json
(
path
=
path
,
msg
=
'chown failed'
)
return
True
...
...
@@ -173,8 +178,13 @@ def set_group_if_different(path, group, changed):
return
changed
old_user
,
old_group
=
user_and_group
(
path
)
if
old_group
!=
group
:
rc
=
os
.
system
(
"/bin/chgrp -R
%
s
%
s"
%
(
group
,
path
))
if
rc
!=
0
:
try
:
gid
=
grp
.
getgrnam
(
group
)
.
gr_gid
except
KeyError
:
module_fail_json
(
path
=
path
,
msg
=
'chgrp failed: failed to look up group
%
s'
%
group
)
try
:
os
.
chown
(
path
,
-
1
,
gid
)
except
OSError
:
module_fail_json
(
path
=
path
,
msg
=
'chgrp failed'
)
return
True
return
changed
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment