summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorjctanner <tanner.jc@gmail.com>2014-01-20 06:11:29 -0800
committerjctanner <tanner.jc@gmail.com>2014-01-20 06:11:29 -0800
commit7b76ad9e623c84628645a04e5fcdd7a46af803cd (patch)
tree1f8fce613f5b2a1ef1dcbc4dcc99dd6c596f23a4 /library
parent2060ae550afe776aafc9861dccb28ee44f9db9c3 (diff)
parent3db808c840d0da29c0a555fc2385172583b2ee83 (diff)
downloadansible-7b76ad9e623c84628645a04e5fcdd7a46af803cd.tar.gz
Merge pull request #5676 from simonz05/bugfix-sysctl-multivalue2
Correctly compare values returned by 'sysctl -e -n'
Diffstat (limited to 'library')
-rw-r--r--library/system/sysctl17
1 files changed, 16 insertions, 1 deletions
diff --git a/library/system/sysctl b/library/system/sysctl
index 3541a45aee..2b09d06a6f 100644
--- a/library/system/sysctl
+++ b/library/system/sysctl
@@ -148,7 +148,7 @@ class SysctlModule(object):
if self.args['sysctl_set']:
if self.proc_value is None:
self.changed = True
- elif self.proc_value != self.args['value']:
+ elif not self._values_is_equal(self.proc_value, self.args['value']):
self.changed = True
self.set_proc = True
@@ -161,6 +161,21 @@ class SysctlModule(object):
if self.set_proc:
self.set_token_value(self.args['name'], self.args['value'])
+ def _values_is_equal(self, a, b):
+ """Expects two string values. It will split the string by whitespace
+ and compare each value. It will return True if both lists are the same,
+ contain the same elements and the same order."""
+ if a is None or b is None:
+ return False
+
+ a = a.split()
+ b = b.split()
+
+ if len(a) != len(b):
+ return False
+
+ return len([i for i, j in zip(a, b) if i == j]) == len(a)
+
# ==============================================================
# SYSCTL COMMAND MANAGEMENT
# ==============================================================