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

Fix service module for issue 755 and another bug

Allow use of service module with just enable parameter, per issue #755.
Also fixed two other issues:
- fixed parameter to be 'enabled' per docs, not 'enable'.
- fixed if block that checks whether to run _do_enable() to check
  whether the parameter is set, not the value of the enable value which
  may be None or False.  If enabled=no, the service would never be
  disabled.
This commit is contained in:
Stephen Fromm 2012-08-01 14:44:26 -07:00
parent 2d9ceafbd4
commit 42ad1c879f

View file

@ -132,14 +132,14 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec = dict(
name = dict(required=True), name = dict(required=True),
state = dict(required=True, choices=['running', 'started', 'stopped', 'restarted', 'reloaded']), state = dict(choices=['running', 'started', 'stopped', 'restarted', 'reloaded']),
enable = dict(choices=BOOLEANS) enabled = dict(choices=BOOLEANS)
) )
) )
name = module.params['name'] name = module.params['name']
state = module.params['state'] state = module.params['state']
enable = module.boolean(module.params.get('enable', None)) enable = module.boolean(module.params.get('enabled', None))
# =========================================== # ===========================================
# find binaries locations on minion # find binaries locations on minion
@ -156,7 +156,7 @@ def main():
err = '' err = ''
out = '' out = ''
if enable: if module.params['enabled']:
rc_enable, out_enable, err_enable = _do_enable(name, enable) rc_enable, out_enable, err_enable = _do_enable(name, enable)
rc += rc_enable rc += rc_enable
out += out_enable out += out_enable