community.general.svc module – Manage daemontools services

Note

This module is part of the community.general collection (version 8.5.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.svc.

Synopsis

  • Controls daemontools services on remote hosts using the svc utility.

Aliases: system.svc

Parameters

Parameter

Comments

downed

boolean

Should a ‘down’ file exist or not, if it exists it disables auto startup. Defaults to no. Downed does not imply stopped.

Choices:

  • false

  • true

enabled

boolean

Whether the service is enabled or not, if disabled it also implies stopped. Take note that a service can be enabled and downed (no auto restart).

Choices:

  • false

  • true

name

string / required

Name of the service to manage.

service_dir

string

Directory svscan watches for services

Default: "/service"

service_src

string

Directory where services are defined, the source of symlinks to service_dir.

Default: "/etc/service"

state

string

started/stopped are idempotent actions that will not run commands unless necessary. restarted will always bounce the svc (svc -t) and killed will always bounce the svc (svc -k). reloaded will send a sigusr1 (svc -1). once will run a normally downed svc once (svc -o), not really an idempotent operation.

Choices:

  • "killed"

  • "once"

  • "reloaded"

  • "restarted"

  • "started"

  • "stopped"

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Start svc dnscache, if not running
  community.general.svc:
    name: dnscache
    state: started

- name: Stop svc dnscache, if running
  community.general.svc:
    name: dnscache
    state: stopped

- name: Kill svc dnscache, in all cases
  community.general.svc:
    name: dnscache
    state: killed

- name: Restart svc dnscache, in all cases
  community.general.svc:
    name: dnscache
    state: restarted

- name: Reload svc dnscache, in all cases
  community.general.svc:
    name: dnscache
    state: reloaded

- name: Using alternative svc directory location
  community.general.svc:
    name: dnscache
    state: reloaded
    service_dir: /var/service

Authors

  • Brian Coca (@bcoca)