From a3de4db57d76aaccccad8312c3c4a8504fd8d021 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Jan 2015 13:16:53 -0500 Subject: [PATCH] fix for allowing permissions on hard links and soft links + follow=yes --- lib/ansible/modules/files/file.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ansible/modules/files/file.py b/lib/ansible/modules/files/file.py index 002776fd6ff..35bb52ab1e3 100644 --- a/lib/ansible/modules/files/file.py +++ b/lib/ansible/modules/files/file.py @@ -218,7 +218,15 @@ def main(): module.exit_json(path=path, changed=False) elif state == 'file': + if state != prev_state: + if follow and prev_state == 'link': + # follow symlink and operate on original + path = os.readlink(path) + prev_state = get_state(path) + file_args['path'] = path + + if prev_state not in ['file','hard']: # file is not absent and any other state is a conflict module.fail_json(path=path, msg='file (%s) is %s, cannot continue' % (path, prev_state))