community.general.svc – Manage daemontools services

Note

This plugin is part of the community.general collection (version 2.2.0).

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.

Parameters

Parameter Choices/Defaults Comments
downed
boolean
    Choices:
  • no
  • yes
Should a 'down' file exist or not, if it exists it disables auto startup. Defaults to no. Downed does not imply stopped.
enabled
boolean
    Choices:
  • no
  • yes
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).
name
string / required
Name of the service to manage.
service_dir
string
Default:
"/service"
Directory svscan watches for services
service_src
string
Default:
"/etc/service"
Directory where services are defined, the source of symlinks to service_dir.
state
string
    Choices:
  • killed
  • once
  • reloaded
  • restarted
  • started
  • stopped
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.

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)