1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

sysctl: parse bool value as 0/1 and refactor a little bit

This commit is contained in:
Jakub Jirutka 2014-01-27 20:26:11 +01:00
parent 8ff1b06879
commit 8c9a63bcd0

View file

@ -120,10 +120,7 @@ class SysctlModule(object):
# Whitespace is bad
self.args['name'] = self.args['name'].strip()
if self.args['value'] is not None:
self.args['value'] = self.args['value'].strip()
else:
self.args['value'] = ""
self.args['value'] = self._parse_value(self.args['value'])
thisname = self.args['name']
@ -176,6 +173,16 @@ class SysctlModule(object):
return len([i for i, j in zip(a, b) if i == j]) == len(a)
def _parse_value(self, value):
if value is None:
return ''
elif value.lower() in BOOLEANS_TRUE:
return '1'
elif value.lower() in BOOLEANS_FALSE:
return '0'
else:
return value.strip()
# ==============================================================
# SYSCTL COMMAND MANAGEMENT
# ==============================================================