|
|
@ -37,7 +37,8 @@ options:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- C(started)/C(stopped) are idempotent actions that will not run
|
|
|
|
- C(started)/C(stopped) are idempotent actions that will not run
|
|
|
|
commands unless necessary. C(restarted) will always bounce the
|
|
|
|
commands unless necessary. C(restarted) will always bounce the
|
|
|
|
service. C(reloaded) will always reload.
|
|
|
|
service. C(reloaded) will always reload. At least one of state
|
|
|
|
|
|
|
|
and enabled are required.
|
|
|
|
pattern:
|
|
|
|
pattern:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
version_added: "0.7"
|
|
|
|
version_added: "0.7"
|
|
|
@ -50,7 +51,9 @@ options:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
choices: [ "yes", "no" ]
|
|
|
|
choices: [ "yes", "no" ]
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Whether the service should start on boot.
|
|
|
|
- Whether the service should start on boot. At least one of state and
|
|
|
|
|
|
|
|
enabled are required.
|
|
|
|
|
|
|
|
|
|
|
|
arguments:
|
|
|
|
arguments:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Additional arguments provided on the command line
|
|
|
|
- Additional arguments provided on the command line
|
|
|
@ -64,6 +67,8 @@ examples:
|
|
|
|
code: "service: name=httpd state=restarted"
|
|
|
|
code: "service: name=httpd state=restarted"
|
|
|
|
- description: Example action to reload service httpd, in all cases
|
|
|
|
- description: Example action to reload service httpd, in all cases
|
|
|
|
code: "service: name=httpd state=reloaded"
|
|
|
|
code: "service: name=httpd state=reloaded"
|
|
|
|
|
|
|
|
- description: Example action to enable service httpd, and not touch the running state
|
|
|
|
|
|
|
|
code: "service: name=httpd enabled=yes"
|
|
|
|
- description: Example action to start service foo, based on running process /usr/bin/foo
|
|
|
|
- description: Example action to start service foo, based on running process /usr/bin/foo
|
|
|
|
code: "service: name=foo pattern=/usr/bin/foo state=started"
|
|
|
|
code: "service: name=foo pattern=/usr/bin/foo state=started"
|
|
|
|
- description: Example action to restart network service for interface eth0
|
|
|
|
- description: Example action to restart network service for interface eth0
|
|
|
@ -856,6 +861,8 @@ def main():
|
|
|
|
),
|
|
|
|
),
|
|
|
|
supports_check_mode=True
|
|
|
|
supports_check_mode=True
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
if module.params['state'] is None and module.params['enabled'] is None:
|
|
|
|
|
|
|
|
module.fail_json(msg="Neither 'state' nor 'enabled' set")
|
|
|
|
|
|
|
|
|
|
|
|
service = Service(module)
|
|
|
|
service = Service(module)
|
|
|
|
|
|
|
|
|
|
|
@ -870,7 +877,6 @@ def main():
|
|
|
|
err = ''
|
|
|
|
err = ''
|
|
|
|
result = {}
|
|
|
|
result = {}
|
|
|
|
result['name'] = service.name
|
|
|
|
result['name'] = service.name
|
|
|
|
result['state'] = service.state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Find service management tools
|
|
|
|
# Find service management tools
|
|
|
|
service.get_service_tools()
|
|
|
|
service.get_service_tools()
|
|
|
@ -880,6 +886,14 @@ def main():
|
|
|
|
# FIXME: ideally this should detect if we need to toggle the enablement state, though
|
|
|
|
# FIXME: ideally this should detect if we need to toggle the enablement state, though
|
|
|
|
# it's unlikely the changed handler would need to fire in this case so it's a minor thing.
|
|
|
|
# it's unlikely the changed handler would need to fire in this case so it's a minor thing.
|
|
|
|
service.service_enable()
|
|
|
|
service.service_enable()
|
|
|
|
|
|
|
|
result['enabled'] = service.enable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if module.params['state'] is None:
|
|
|
|
|
|
|
|
# Not changing the running state, so bail out now.
|
|
|
|
|
|
|
|
result['changed'] = service.changed
|
|
|
|
|
|
|
|
module.exit_json(**result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result['state'] = service.state
|
|
|
|
|
|
|
|
|
|
|
|
# Collect service status
|
|
|
|
# Collect service status
|
|
|
|
if service.pattern:
|
|
|
|
if service.pattern:
|
|
|
|