mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #3666 from bpennypacker/statdoc
doc update for stat module
This commit is contained in:
commit
ed55ac1a15
1 changed files with 8 additions and 1 deletions
|
@ -40,10 +40,17 @@ author: Bruce Pennypacker
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
# Obtain the stats of /etc/foo.conf, and check that the file still belongs
|
# Obtain the stats of /etc/foo.conf, and check that the file still belongs
|
||||||
# to 'root'. Fail otherwise.
|
# to 'root'. Fail otherwise.
|
||||||
- stats: path=/etc/foo.conf
|
- stat: path=/etc/foo.conf
|
||||||
register: st
|
register: st
|
||||||
- fail: msg="Whoops! file ownership has changed"
|
- fail: msg="Whoops! file ownership has changed"
|
||||||
when: st.stat.pw_name != 'root'
|
when: st.stat.pw_name != 'root'
|
||||||
|
|
||||||
|
# Determine if a path exists and is a directory. Note we need to test
|
||||||
|
# both that p.stat.isdir actually exists, and also that it's set to true.
|
||||||
|
- stat: path=/path/to/something
|
||||||
|
register: p
|
||||||
|
- debug: msg="Path exists and is a directory"
|
||||||
|
when: p.stat.isdir is defined and p.stat.isdir == true
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
Loading…
Reference in a new issue