Improve check mode reporting for directories and file modes.

This commit is contained in:
Michael DeHaan 2013-05-11 15:04:42 -04:00
parent 71f77d1583
commit 3afa8b373e
2 changed files with 8 additions and 6 deletions

View file

@ -196,12 +196,14 @@ def main():
if prev_state != 'absent' and state == 'absent':
try:
if prev_state == 'directory':
if module.check_mode:
module.exit_json(changed=True)
if os.path.islink(path):
if module.check_mode:
module.exit_json(changed=True)
os.unlink(path)
else:
try:
if module.check_mode:
module.exit_json(changed=True)
shutil.rmtree(path, ignore_errors=False)
except:
module.exit_json(msg="rmtree failed")