community.general.svc (8.5.0) — module

Manage daemontools services

Authors: Brian Coca (@bcoca)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Controls daemontools services on remote hosts using the svc utility.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Start svc dnscache, if not running
  community.general.svc:
    name: dnscache
    state: started
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Stop svc dnscache, if running
  community.general.svc:
    name: dnscache
    state: stopped
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Kill svc dnscache, in all cases
  community.general.svc:
    name: dnscache
    state: killed
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Restart svc dnscache, in all cases
  community.general.svc:
    name: dnscache
    state: restarted
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Reload svc dnscache, in all cases
  community.general.svc:
    name: dnscache
    state: reloaded
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Using alternative svc directory location
  community.general.svc:
    name: dnscache
    state: reloaded
    service_dir: /var/service

Inputs

    
name:
    description:
    - Name of the service to manage.
    required: true
    type: str

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

downed:
    description:
    - Should a 'down' file exist or not, if it exists it disables auto startup. Defaults
      to no. Downed does not imply stopped.
    type: bool

enabled:
    description:
    - 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).
    type: bool

service_dir:
    default: /service
    description:
    - Directory svscan watches for services
    type: str

service_src:
    default: /etc/service
    description:
    - Directory where services are defined, the source of symlinks to service_dir.
    type: str