service

Collection: builtin

Full Name: parallax.builtin.service

Aliases: ansible.builtin.service, service

Synopsis

Start, stop, restart and enable services on any init system

Parameters

NameTypeRequiredDefaultDescription
namestringyesName of the service
statestringstartedstarted/stopped/restarted/reloaded
enabledboolWhether the service should start on boot
daemon_reloadboolfalseRun daemon-reload before doing any other operations
usestringautoThe service module implementation to use
argumentsstringAdditional arguments provided on the command line
patternstringIf the service does not respond to the status command, name a substring to look for
runlevelstringdefaultFor OpenRC init scripts, the runlevel to manage
sleepint0If the service is being restarted then sleep this many seconds

Example

- name: Ensure nginx is running and starts at boot
  service:
    name: nginx
    state: started
    enabled: true