From ed1d80b7d84c686a68b9676e2b61379d31bf74d8 Mon Sep 17 00:00:00 2001 From: tobixx Date: Thu, 14 Jul 2016 19:11:35 +0200 Subject: [PATCH] added read-/write-/executeable flags for invoking user (#4130) --- lib/ansible/modules/files/stat.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/ansible/modules/files/stat.py b/lib/ansible/modules/files/stat.py index e2b534c4ec4..facdd8fb544 100644 --- a/lib/ansible/modules/files/stat.py +++ b/lib/ansible/modules/files/stat.py @@ -294,6 +294,21 @@ stat: returned: success, path exists and user can read stats and installed python supports it and the `mime` option was true, will return 'unknown' on error. type: string sample: us-ascii + readable: + description: Tells you if the invoking user has the right to read the path + returned: success, path exists and user can read the path + type: boolean + sample: False + writeable: + description: Tells you if the invoking user has the right to write the path + returned: success, path exists and user can write the path + type: boolean + sample: False + executable: + description: Tells you if the invoking user has the execute the path + returned: success, path exists and user can execute the path + type: boolean + sample: False ''' import os @@ -368,6 +383,9 @@ def main(): 'xoth' : bool(mode & stat.S_IXOTH), 'isuid' : bool(mode & stat.S_ISUID), 'isgid' : bool(mode & stat.S_ISGID), + 'readable' : os.access(path, os.R_OK), + 'writeable' : os.access(path, os.W_OK), + 'excutable' : os.access(path, os.X_OK), } if S_ISLNK(mode):