community.general.systemd_info module – Gather systemd
unit info
Note
This module is part of the community.general collection (version 10.4.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.systemd_info
.
New in community.general 10.4.0
Synopsis
This module gathers info about systemd units (services, targets, sockets, mount).
It runs
systemctl list-units
(or processes selected units) and collects properties for each unit usingsystemctl show
.Even if a unit has a
units.loadstate
ofnot-found
ormasked
, it is returned, but only with the minimal properties (units.name
,units.loadstate
,units.activestate
,units.substate
).When
unitname
andextra_properties
are used, the module first checks if the unit exists, then check if properties exist. If not, the module fails.
Parameters
Parameter |
Comments |
---|---|
Additional properties to retrieve (appended to the default ones). Note that all property names are converted to lower-case. Default: |
|
List of unit names to process. It supports Each name must correspond to the full name of the Default: |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full This action does not modify state. |
Can run in |
|
Support: N/A This action does not modify state. |
Will return details on what has changed (or possibly needs changing in |
Examples
---
# Gather info for all systemd services, targets, sockets and mount
- name: Gather all systemd unit info
community.general.systemd_info:
register: results
# Gather info for selected units with extra properties.
- name: Gather info for selected unit(s)
community.general.systemd_info:
unitname:
- systemd-journald.service
- systemd-journald.socket
- sshd-keygen.target
- -.mount
extra_properties:
- Description
register: results
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Dictionary of systemd unit info keyed by unit name. Additional fields will be returned depending on the value of Returned: success Sample: |
|
The current active state of the unit. The most common values are Returned: always Sample: |
|
PID of the ExecStart process of the unit. Returned: only for Sample: |
|
Path to the unit’s fragment file. Returned: always except for Sample: |
|
The state of the unit’s configuration load. The most common values are Returned: always Sample: |
|
PID of the main process of the unit. Returned: only for Sample: |
|
Unit full name. Returned: always Sample: |
|
The mount options. Returned: only for Sample: |
|
The detailed sub state of the unit. The most common values are Returned: always Sample: |
|
The filesystem type of the mounted device. Returned: only for Sample: |
|
The preset configuration state for the unit file. The most common values are Returned: always except for Sample: |
|
The actual configuration state for the unit file. The most common values are Returned: always except for Sample: |
|
The device that is mounted. Returned: only for Sample: |
|
The mount point where the device is mounted. Returned: only for Sample: |