From d2c19eb2f1d3a55f93a7496ec505658a6fba2dc2 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 2 Oct 2017 15:51:40 -0400 Subject: [PATCH] better chown errors (cherry picked from commit a6e27a903aeded6b3d71e1995fcbfdfaa0f7c04d) --- CHANGELOG.md | 1 + lib/ansible/module_utils/basic.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa56cf30ec1..ab1ce8f4ef2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 264152d0b34..8006415df4e 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -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