better chown errors

(cherry picked from commit a6e27a903a)
This commit is contained in:
Brian Coca 2017-10-02 15:51:40 -04:00
parent e80c7d55d8
commit d2c19eb2f1
2 changed files with 3 additions and 2 deletions

View file

@ -104,6 +104,7 @@ Ansible Changes By Release
https://github.com/ansible/ansible/issues/24169
* Do not log data field in `docker_secrets` module (https://github.com/ansible/ansible/pull/31366)
* Fix rpm_key taking the wrong 8 chars from the keyid (https://github.com/ansible/ansible/pull/31045)
* chown errors now more informative
<a id="2.4"></a>

View file

@ -1133,9 +1133,9 @@ class AnsibleModule(object):
return True
try:
os.lchown(b_path, uid, -1)
except OSError:
except (IOError, OSError) as e:
path = to_text(b_path)
self.fail_json(path=path, msg='chown failed')
self.fail_json(path=path, msg='chown failed: %s' % (to_text(e)))
changed = True
return changed