Skip to content

Commit a7fcca2

Browse files
Update SystemdService.exists to find all unit files
1 parent cb46ffa commit a7fcca2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

testinfra/modules/service.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,12 @@ def _has_systemd_suffix(self):
176176

177177
@property
178178
def exists(self):
179-
cmd = self.run_test('systemctl list-unit-files | grep -q"^%s"', self.name)
179+
# list-unit-files: Older systemd versions only show native unit files
180+
# list-units: List all units that Systemd currently has in memory,
181+
# this includes generated units like SysV files also
182+
cmd = self.run_test(
183+
r'systemctl list-units --all | grep -q "^[[:space:]]*%s"', self.name
184+
)
180185
return cmd.rc == 0
181186

182187
@property

0 commit comments

Comments
 (0)