Handle None and Blank value for sysctl module (#24871)
Fix adds check for values provided by user for name and value in sysctl module. While providing name and value as in-line params, check for blank values Fixes #20176 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
7c325470e2
commit
650b5fedb1
1 changed files with 13 additions and 1 deletions
|
@ -386,9 +386,21 @@ def main():
|
|||
ignoreerrors = dict(default=False, type='bool'),
|
||||
sysctl_file = dict(default='/etc/sysctl.conf', type='path')
|
||||
),
|
||||
supports_check_mode=True
|
||||
supports_check_mode=True,
|
||||
required_if=[('state', 'present', ['value'])],
|
||||
)
|
||||
|
||||
if module.params['name'] is None:
|
||||
module.fail_json(msg="name can not be None")
|
||||
if module.params['state'] == 'present' and module.params['value'] is None:
|
||||
module.fail_json(msg="value can not be None")
|
||||
|
||||
# In case of in-line params
|
||||
if module.params['name'] == '':
|
||||
module.fail_json(msg="name can not be blank")
|
||||
if module.params['state'] == 'present' and module.params['value'] == '':
|
||||
module.fail_json(msg="value can not be blank")
|
||||
|
||||
result = SysctlModule(module)
|
||||
|
||||
module.exit_json(changed=result.changed)
|
||||
|
|
Loading…
Reference in a new issue