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

Return service state information as fact data

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

Authors: Matthew Jones, Adam Miller (@maxamillion)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.7.18

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
  service_facts:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: ansible_facts.services

Outputs

ansible_facts:
  contains:
    services:
      contains:
        name:
          description: Name of the service.
          returned: always
          sample: arp-ethers.service
          type: string
        source:
          description: Init system of the service. One of C(systemd), C(sysv), C(upstart).
          returned: always
          sample: sysv
          type: string
        state:
          description: State of the service. Either C(running) or C(stopped).
          returned: always
          sample: running
          type: string
      description: States of the services with service name as key.
      returned: always
      type: complex
  description: Facts to add to ansible_facts about the services on the system
  returned: always
  type: complex