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
9a82d8c6
Commit
9a82d8c6
authored
Jul 03, 2013
by
Jan-Piet Mens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
files/stat: add pw_name and md5 sum to stat, and add meaningful? example
remove unnecessary import, md5 sum on regular files only
parent
f8396622
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
library/files/stat
+17
-5
No files found.
library/files/stat
View file @
9a82d8c6
...
@@ -32,16 +32,18 @@ author: Bruce Pennypacker
...
@@ -32,16 +32,18 @@ author: Bruce Pennypacker
'''
'''
EXAMPLES
=
'''
EXAMPLES
=
'''
# Obtain the stats of /etc/foo.conf
# Obtain the stats of /etc/foo.conf, and check that the file still belongs
- stats: >
# to 'root'. Fail otherwise.
path=/etc/foo.conf
- stats: path=/etc/foo.conf
register: st
- fail: msg="Whoops! file ownership has changed"
when: st.stat.pw_name != 'root'
'''
'''
import
os
import
os
import
sys
import
sys
from
stat
import
*
from
stat
import
*
from
pprint
import
pprint
import
pwd
def
main
():
def
main
():
module
=
AnsibleModule
(
module
=
AnsibleModule
(
...
@@ -99,6 +101,16 @@ def main():
...
@@ -99,6 +101,16 @@ def main():
if
S_ISDIR
(
mode
)
and
os
.
path
.
islink
(
path
):
if
S_ISDIR
(
mode
)
and
os
.
path
.
islink
(
path
):
d
[
'isdir'
]
=
False
d
[
'isdir'
]
=
False
d
[
'islnk'
]
=
True
d
[
'islnk'
]
=
True
if
S_ISREG
(
mode
):
d
[
'md5'
]
=
module
.
md5
(
path
)
try
:
pw
=
pwd
.
getpwuid
(
st
.
st_uid
)
d
[
'pw_name'
]
=
pw
.
pw_name
except
:
pass
module
.
exit_json
(
changed
=
False
,
stat
=
d
)
module
.
exit_json
(
changed
=
False
,
stat
=
d
)
...
...
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