From c47d12148140ff3e456998f8d2b3f02bdaf356bd Mon Sep 17 00:00:00 2001 From: Bruce Pennypacker Date: Wed, 26 Jun 2013 12:32:28 -0400 Subject: [PATCH] don't fail if the file doesn't exist. Just set 'exists' to true/false as appropriate --- library/files/stat | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/files/stat b/library/files/stat index f05317f873..95a630e7d5 100644 --- a/library/files/stat +++ b/library/files/stat @@ -55,12 +55,17 @@ def main(): try: st = os.stat(path) except OSError, e: + if e.errno == errno.ENOENT: + d = { 'exists' : False } + module.exit_json(changed=False, stat=d) + module.fail_json(msg = e.strerror) mode = st.st_mode # back to ansible d = { + 'exists' : True, 'mode' : S_IMODE(mode), 'isdir' : S_ISDIR(mode), 'ischr' : S_ISCHR(mode),