13
13
module: systemd_info
14
14
short_description: Gather C(systemd) unit info
15
15
description:
16
- - This module gathers info about systemd units (services, targets, sockets, mount).
16
+ - This module gathers info about systemd units (services, targets, sockets, mounts, timers).
17
+ - Timer units are supported since community.general 10.5.0.
17
18
- It runs C(systemctl list-units) (or processes selected units) and collects properties
18
19
for each unit using C(systemctl show).
20
+ - In case a unit has multiple properties with the same name, only the value of the first one will be collected.
19
21
- Even if a unit has a RV(units.loadstate) of V(not-found) or V(masked), it is returned,
20
22
but only with the minimal properties (RV(units.name), RV(units.loadstate), RV(units.activestate), RV(units.substate)).
21
23
- When O(unitname) and O(extra_properties) are used, the module first checks if the unit exists,
27
29
unitname:
28
30
description:
29
31
- List of unit names to process.
30
- - It supports C(.service), C(.target), C(.socket), and C(.mount) units type.
32
+ - It supports C(.service), C(.target), C(.socket), C(.mount) and C(.timer) units type.
33
+ - C(.timer) units are supported since community.general 10.5.0.
31
34
- Each name must correspond to the full name of the C(systemd) unit or to a wildcard expression like V('ssh*') and V('*.service').
32
35
- Wildcard expressions in O(unitname) are supported since community.general 10.5.0.
33
36
type: list
49
52
50
53
EXAMPLES = r'''
51
54
---
52
- # Gather info for all systemd services, targets, sockets and mount
55
+ # Gather info for all systemd services, targets, sockets, mount and timer
53
56
- name: Gather all systemd unit info
54
57
community.general.systemd_info:
55
58
register: results
72
75
unitname:
73
76
- 'systemd-*'
74
77
register: results
78
+
79
+ # Gather info for systemd-tmpfiles-clean.timer with extra properties
80
+ - name: Gather info of systemd-tmpfiles-clean.timer and extra AccuracyUSec
81
+ community.general.systemd_info:
82
+ unitname:
83
+ - systemd-tmpfiles-clean.timer
84
+ extra_properties:
85
+ - AccuracyUSec
86
+ register: results
75
87
'''
76
88
77
89
RETURN = r'''
@@ -255,6 +267,8 @@ def determine_category(unit):
255
267
return 'socket'
256
268
elif unit .endswith ('.mount' ):
257
269
return 'mount'
270
+ elif unit .endswith ('.timer' ):
271
+ return 'timer'
258
272
else :
259
273
return None
260
274
@@ -275,7 +289,8 @@ def get_category_base_props(category):
275
289
'service' : ['FragmentPath' , 'UnitFileState' , 'UnitFilePreset' , 'MainPID' , 'ExecMainPID' ],
276
290
'target' : ['FragmentPath' , 'UnitFileState' , 'UnitFilePreset' ],
277
291
'socket' : ['FragmentPath' , 'UnitFileState' , 'UnitFilePreset' ],
278
- 'mount' : ['Where' , 'What' , 'Options' , 'Type' ]
292
+ 'mount' : ['Where' , 'What' , 'Options' , 'Type' ],
293
+ 'timer' : ['FragmentPath' , 'UnitFileState' , 'UnitFilePreset' ],
279
294
}
280
295
return base_props .get (category , [])
281
296
@@ -364,7 +379,7 @@ def main():
364
379
state_props = ['LoadState' , 'ActiveState' , 'SubState' ]
365
380
results = {}
366
381
367
- unit_types = ["service" , "target" , "socket" , "mount" ]
382
+ unit_types = ["service" , "target" , "socket" , "mount" , "timer" ]
368
383
369
384
list_output = list_units (base_runner , unit_types )
370
385
units_info = {}
0 commit comments