ansible.builtin.service_facts – Return service state information as fact data
Note
This module is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
module name
service_facts
even without specifying the collections:
keyword.
However, we recommend you use the FQCN for easy linking to the
module documentation and to avoid conflicting with other collections that may have
the same module name.
New in version 2.5: of ansible.builtin
Requirements
The below requirements are needed on the host that executes this module.
Any of the following supported init systems: systemd, sysv, upstart, AIX SRC
Notes
Note
When accessing the
ansible_facts.services
facts collected by this module, it is recommended to not use “dot notation” because services can have a-
character in their name which would result in invalid “dot notation”, such asansible_facts.services.zuul-gateway
. It is instead recommended to using the string value of the service name as the key in order to obtain the fact data value likeansible_facts.services['zuul-gateway']
AIX SRC was added in version 2.11.
Supports
check_mode
.
Examples
- name: Populate service facts
ansible.builtin.service_facts:
- name: Print service facts
ansible.builtin.debug:
var: ansible_facts.services
Returned Facts
Facts returned by this module are added/updated in the hostvars
host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.
Key |
Description |
---|---|
States of the services with service name as key. Returned: always |
|
Name of the service. Returned: always Sample: “arp-ethers.service” |
|
Init system of the service. One of Returned: always Sample: “sysv” |
|
State of the service. Either Returned: always Sample: “running” |
|
State of the service. Either Returned: systemd systems or RedHat/SUSE flavored sysvinit/upstart or OpenBSD Sample: “enabled” |
Authors
Adam Miller (@maxamillion)