diff options
| author | Abhijeet Kasurde <akasurde@redhat.com> | 2017-05-25 21:19:20 +0530 |
|---|---|---|
| committer | jctanner <tanner.jc@gmail.com> | 2017-05-25 11:49:20 -0400 |
| commit | 650b5fedb13968b3ca4220713afba72f4f943ef5 (patch) | |
| tree | ec4ed690f1a25f22c8d6dd3f92073c2036a9f6b2 | |
| parent | 7c325470e243477c13776d52636b6c582d557f48 (diff) | |
| download | ansible-650b5fedb13968b3ca4220713afba72f4f943ef5.tar.gz | |
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>
| -rw-r--r-- | lib/ansible/modules/system/sysctl.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/ansible/modules/system/sysctl.py b/lib/ansible/modules/system/sysctl.py index 98826c5eb3..e2a88c89f2 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) |
