New in version 2.6.
The below requirements are needed on the host that executes this module.
Parameter | Choices/Defaults | Comments |
---|---|---|
arguments - | Additional arguments provided on the command line that some init scripts accept. aliases: args | |
daemonize boolean |
| Have the module daemonize as the service itself might not do so properly. This is useful with badly written init scripts or daemons, which commonly manifests as the task hanging as it is still holding the tty or the service dying when the task is over as the connection closes the session. |
enabled boolean |
| Whether the service should start on boot. At least one of state and enabled are required.
|
name - / required | Name of the service. aliases: service | |
pattern - | A substring to look for as would be found in the output of the ps command as a stand-in for a status result. If the string is found, the service will be assumed to be running. This option is mainly for use with init scripts that don't support the 'status' option. | |
runlevels - | The runlevels this script should be enabled/disabled from. Use this to override the defaults set by the package or init script itself. | |
sleep - | Default: 1 | If the service is being restarted or reloaded then sleep this many seconds between the stop and start command. This helps to workaround badly behaving services. |
state - |
| started /stopped are idempotent actions that will not run commands unless necessary. Not all init scripts support restarted nor reloaded natively, so these will both trigger a stop and start as needed. |
Note
- name: make sure apache2 is started sysvinit: name: apache2 state: started enabled: yes - name: make sure apache2 is started on runlevels 3 and 5 sysvinit: name: apache2 state: started enabled: yes runlevels: - 3 - 5
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
results complex | always | results from actions taken Sample: {'attempts': 1, 'changed': True, 'name': 'apache2', 'status': {'enabled': {'changed': True, 'rc': 0, 'stderr': '', 'stdout': ''}, 'stopped': {'changed': True, 'rc': 0, 'stderr': '', 'stdout': 'Stopping web server: apache2.\n'}}} |
More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.
Hint
If you notice any issues in this documentation, you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/modules/sysvinit_module.html