ansible / ansible.builtin / v2.9.26 / module / sysvinit Manage SysV services. | "added in version" 2.6 of ansible.builtin" Authors: Ansible Core Team preview | supported by coreansible.builtin.sysvinit (v2.9.26) — module
pip
Install with pip install ansible==2.9.26
Controls services on target hosts that use the SysV init system.
- 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
name: aliases: - service description: - Name of the service. required: true sleep: default: 1 description: - If the service is being C(restarted) or C(reloaded) then sleep this many seconds between the stop and start command. This helps to workaround badly behaving services. state: choices: - started - stopped - restarted - reloaded description: - C(started)/C(stopped) are idempotent actions that will not run commands unless necessary. Not all init scripts support C(restarted) nor C(reloaded) natively, so these will both trigger a stop and start as needed. enabled: description: - Whether the service should start on boot. B(At least one of state and enabled are required.) type: bool pattern: description: - A substring to look for as would be found in the output of the I(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. arguments: aliases: - args description: - Additional arguments provided on the command line that some init scripts accept. daemonize: default: false description: - 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. type: bool runlevels: description: - The runlevels this script should be enabled/disabled from. - Use this to override the defaults set by the package or init script itself.
results: description: results from actions taken returned: always 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. ' type: complex