Skip to content

Commit 5698bf1

Browse files
maisimFizzadar
authored andcommitted
feat(facts.zfs): add check_preconditions for ZfsDatasets and update command method
1 parent a2252c3 commit 5698bf1

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/pyinfra/facts/zfs.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,24 @@ def process(self, output):
3434

3535

3636
class ZfsDatasets(FactBase):
37-
@override
38-
def command(self) -> str:
39-
return "zfs get -H all"
40-
4137
@override
4238
def requires_command(self) -> str:
4339
return "zfs"
4440

4541
default = dict
4642

43+
@override
44+
def check_preconditions(self, state, host):
45+
from pyinfra.facts.server import KernelModules
46+
47+
modules = host.get_fact(KernelModules) or {}
48+
if "zfs" not in modules:
49+
return "kernel module 'zfs' is not loaded"
50+
51+
@override
52+
def command(self) -> str:
53+
return "zfs get -H all"
54+
4755
@override
4856
def process(self, output):
4957
return _process_zfs_props_table(output)

0 commit comments

Comments
 (0)