ansible.builtin.service_facts (v2.16.5) — module

Return service state information as fact data

| "added in version" 2.5 of ansible.builtin"

Authors: Adam Miller (@maxamillion)

Install Ansible via pip

Install with pip install ansible-core==2.16.5

Description

Return service state information as fact data for various service management utilities.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Populate service facts
  ansible.builtin.service_facts:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Print service facts
  ansible.builtin.debug:
    var: ansible_facts.services

Outputs

ansible_facts:
  contains:
    services:
      contains:
        name:
          description: Name of the service.
          returned: always
          sample: arp-ethers.service
          type: str
        source:
          description:
          - Init system of the service.
          - One of V(rcctl), V(systemd), V(sysv), V(upstart), V(src).
          returned: always
          sample: sysv
          type: str
        state:
          description:
          - State of the service.
          - 'This commonly includes (but is not limited to) the following: V(failed),
            V(running), V(stopped) or V(unknown).'
          - Depending on the used init system additional states might be returned.
          returned: always
          sample: running
          type: str
        status:
          description:
          - State of the service.
          - Either V(enabled), V(disabled), V(static), V(indirect) or V(unknown).
          returned: systemd systems or RedHat/SUSE flavored sysvinit/upstart or OpenBSD
          sample: enabled
          type: str
      description: States of the services with service name as key.
      elements: dict
      returned: always
      type: list
  description: Facts to add to ansible_facts about the services on the system
  returned: always
  type: complex