From 78cacd0c2270feae0c03624f2e784fca3985c865 Mon Sep 17 00:00:00 2001
From: Brian Coca <brian.coca+git@gmail.com>
Date: Wed, 7 Jan 2015 13:16:53 -0500
Subject: [PATCH] fix for allowing permissions on hard links and soft links +
 follow=yes

---
 files/file.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/files/file.py b/files/file.py
index 002776fd6ff..35bb52ab1e3 100644
--- a/files/file.py
+++ b/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))