items/zfs_pool: rewrite item to support all kinds of zfs pools
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
9111d49bf4
commit
cee2a41771
10 changed files with 134 additions and 117 deletions
|
@ -23,13 +23,13 @@ defaults = {
|
|||
def zfs_disks_to_metadata(metadata):
|
||||
disks = set()
|
||||
|
||||
for _, config in metadata.get('zfs/pools', {}).items():
|
||||
if 'device' in config:
|
||||
disks.add(config['device'])
|
||||
else:
|
||||
for t in {'mirror', 'raidz', 'raidz2', 'raidz3'}:
|
||||
for device in config.get(t, set()):
|
||||
disks.add(device)
|
||||
for config in metadata.get('zfs/pools', {}).values():
|
||||
for option in config:
|
||||
if option.get('type', '') in {'log', 'cache'}:
|
||||
continue
|
||||
|
||||
for disk in option['devices']:
|
||||
disks.add(disk)
|
||||
|
||||
return {
|
||||
'smartd': {
|
||||
|
|
|
@ -79,16 +79,12 @@ svc_systemd = {
|
|||
zfs_datasets = node.metadata.get('zfs/datasets', {})
|
||||
|
||||
for name, attrs in node.metadata.get('zfs/pools', {}).items():
|
||||
zfs_pools[name] = attrs
|
||||
zfs_pools[name] = {
|
||||
'config': attrs,
|
||||
}
|
||||
|
||||
if node.os_version[0] > 10:
|
||||
actions[f'pool_{name}_enable_trim'] = {
|
||||
'command': f'zpool set autotrim=on {name}',
|
||||
'unless': f'zpool get autotrim -H -o value {name} | grep -q on',
|
||||
'needs': [
|
||||
f'zfs_pool:{name}'
|
||||
]
|
||||
}
|
||||
zfs_pools[name]['autotrim'] = True
|
||||
|
||||
directories = {
|
||||
"/etc/zfs-snapshot-backup-pre.d": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue