Skip to main content

systemd

systemd module

Manage systemd services. This module can start, stop, enable, disable services and reload the systemd daemon configuration.

Examples

- name: Start and enable nginx
systemd:
name: nginx
state: started
enabled: true

- name: Stop a service
systemd:
name: apache2
state: stopped

- name: Reload systemd daemon
systemd:
daemon_reload: true

- name: Enable service without starting
systemd:
name: postgresql
enabled: true

Note: This module requires systemd to be the init system on the target host.

Module Capabilities

  • Has Revert: true
  • Provides Variables: None

Inputs

ParameterTypeDescriptionRequiredDefaultChoices
daemon_reloadboolReload systemd daemon configuration before managing the service.falsefalsetrue, false
enabledboolWhether the service should be enabled to start at boot.falsetrue, false
namestringName of the systemd service to manage.true
statestringDesired state of the service.truestarted, stopped, restarted, reloaded

Outputs

No outputs.