diff --git a/lib/ansible/modules/system/sysctl.py b/lib/ansible/modules/system/sysctl.py index 98826c5eb31..e2a88c89f28 100644 --- a/lib/ansible/modules/system/sysctl.py +++ b/lib/ansible/modules/system/sysctl.py @@ -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)