From a88f5f8ae0bd14d9ec16241e7be621c5f61c6ac0 Mon Sep 17 00:00:00 2001 From: satken2 Date: Thu, 10 Jun 2021 23:42:18 +0900 Subject: [PATCH] sysctl: Fixed sysctl to work on symlinks(#111) --- plugins/modules/sysctl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/sysctl.py b/plugins/modules/sysctl.py index 542b3c5..7914e9d 100644 --- a/plugins/modules/sysctl.py +++ b/plugins/modules/sysctl.py @@ -366,7 +366,7 @@ class SysctlModule(object): # Completely rewrite the sysctl file def write_sysctl(self): # open a tmp file - fd, tmp_path = tempfile.mkstemp('.conf', '.ansible_m_sysctl_', os.path.dirname(self.sysctl_file)) + fd, tmp_path = tempfile.mkstemp('.conf', '.ansible_m_sysctl_', os.path.dirname(os.path.realpath(self.sysctl_file))) f = open(tmp_path, "w") try: for l in self.fixed_lines: @@ -377,7 +377,7 @@ class SysctlModule(object): f.close() # replace the real one - self.module.atomic_move(tmp_path, self.sysctl_file) + self.module.atomic_move(tmp_path, os.path.realpath(self.sysctl_file)) # ==============================================================