mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
don't fail if the file doesn't exist. Just set 'exists' to true/false as appropriate
This commit is contained in:
parent
59a045e4cb
commit
c47d121481
1 changed files with 5 additions and 0 deletions
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue