Franziska Kunsmann
72cf616114
Last night, rx300 rebooted. After a reboot, the disks were detected in another order (but still, all were detected!), so the cachefile did no longer match, leading to breaking the import. Running `zpool import` manually worked, because that will ignore the cachefile. So, why do we depend on the cache file on boot up? The added reliability of zfs-import-scan beats the speed of zfs-import-cache in any way.
132 lines
3.8 KiB
Python
132 lines
3.8 KiB
Python
from json import dumps
|
|
#from os.path import join
|
|
|
|
from bundlewrap.metadata import MetadataJSONEncoder
|
|
|
|
if node.os == 'debian':
|
|
actions = {
|
|
# For some reason, this module doesn't get auto-loaded on debian,
|
|
# even if installation of zfsutils-linux tries to start
|
|
# zfs-mount.service. We have no choice but to do it manually.
|
|
'modprobe_zfs': {
|
|
'command': 'modprobe zfs',
|
|
'unless': 'lsmod | grep ^zfs',
|
|
'needs': {
|
|
'pkg_apt:zfs-dkms',
|
|
},
|
|
'needed_by': {
|
|
'pkg_apt:zfs-zed',
|
|
'pkg_apt:zfsutils-linux',
|
|
'zfs_dataset:',
|
|
'zfs_pool:',
|
|
},
|
|
'comment': 'If this fails, do a dist-upgrade, reinstall zfs-dkms, reboot',
|
|
},
|
|
}
|
|
|
|
files = {
|
|
'/etc/modprobe.d/zfs.conf': {
|
|
'source': 'zfs-modprobe.conf',
|
|
'content_type': 'mako',
|
|
'mode': '0755',
|
|
},
|
|
'/etc/systemd/system/zfs-import-scan.service.d/bundlewrap.conf': {
|
|
'source': 'zfs-import-scan-override.service',
|
|
'content_type': 'mako',
|
|
'triggers': {
|
|
'action:systemd-reload',
|
|
},
|
|
},
|
|
'/etc/zfs-snapshot-config.json': {
|
|
'content': dumps(
|
|
node.metadata.get('zfs/snapshots', {}),
|
|
cls=MetadataJSONEncoder, # turns sets into sorted lists
|
|
indent=4,
|
|
sort_keys=True,
|
|
) + '\n',
|
|
},
|
|
'/etc/zfs/zed.d/zed.rc': {
|
|
'content': 'ZED_EMAIL_ADDR="hostmaster@kunbox.net"\nZED_EMAIL_PROG="mail"\nZED_NOTIFY_INTERVAL_SECS=3600\n',
|
|
'mode': '0600',
|
|
'triggers': {
|
|
'svc_systemd:zfs-zed:restart'
|
|
},
|
|
},
|
|
'/usr/local/sbin/telegraf-per-dataset': {
|
|
'mode': '0755',
|
|
},
|
|
'/usr/local/sbin/zfs-auto-snapshot': {
|
|
'mode': '0755',
|
|
},
|
|
'/usr/local/share/icinga/plugins/check_zfs_auto_snapshot': {
|
|
'mode': '0755',
|
|
},
|
|
'/usr/local/share/icinga/plugins/check_zfs_old_snapshots': {
|
|
'mode': '0755',
|
|
},
|
|
"/usr/local/share/icinga/plugins/check_zfs_volumes": {
|
|
'mode': '0755',
|
|
'content_type': 'mako',
|
|
},
|
|
"/usr/local/share/icinga/plugins/check_zpool_online": {
|
|
'mode': '0755',
|
|
},
|
|
"/usr/local/share/icinga/plugins/check_zpool_space": {
|
|
'mode': '0755',
|
|
},
|
|
}
|
|
|
|
svc_systemd = {
|
|
'zfs-import-scan.service': {
|
|
'needs': {
|
|
'file:/etc/systemd/system/zfs-import-scan.service.d/bundlewrap.conf',
|
|
},
|
|
'before': {
|
|
'svc_systemd:zfs-import-cache.service',
|
|
},
|
|
},
|
|
'zfs-import-cache.service': {
|
|
'running': None,
|
|
'enabled': False,
|
|
'masked': True,
|
|
},
|
|
'zfs-mount.service': {},
|
|
'zfs-zed': {},
|
|
'zfs.target': {
|
|
'running': None,
|
|
},
|
|
'zfs-import.target': {
|
|
'running': None,
|
|
},
|
|
}
|
|
|
|
for name, attrs in node.metadata.get('zfs/datasets', {}).items():
|
|
zfs_datasets[name] = attrs
|
|
|
|
if 'mountpoint' not in attrs:
|
|
zfs_datasets[name]['canmount'] = 'off'
|
|
zfs_datasets[name]['mountpoint'] = 'none'
|
|
elif 'canmount' not in attrs:
|
|
zfs_datasets[name]['canmount'] = 'on'
|
|
|
|
for name, attrs in node.metadata.get('zfs/pools', {}).items():
|
|
zfs_pools[name] = attrs
|
|
|
|
if (not node.os == 'debian' or node.os_version[0] > 10) and 'autotrim' not in attrs:
|
|
zfs_pools[name]['autotrim'] = True
|
|
|
|
directories = {
|
|
"/etc/zfs-snapshot-backup-pre.d": {
|
|
'purge': True,
|
|
},
|
|
"/etc/zfs-snapshot-backup-post.d": {
|
|
'purge': True,
|
|
},
|
|
}
|
|
|
|
if node.metadata.get('zfs/filesystems_with_backup_snapshots', {}) and node.has_bundle('backup-client'):
|
|
files['/etc/backup-pre-hooks.d/99-zfs-snapshots'] = {
|
|
'content_type': 'mako',
|
|
'source': 'backup-pre-hook',
|
|
'mode': '0755',
|
|
}
|