Add zfs-load-key service

This commit is contained in:
Benoit S 2021-01-30 20:58:06 +09:00
parent fee88a681d
commit 32404e0ba5

View file

@ -1,5 +1,5 @@
from pyinfra import host
from pyinfra.operations import server, files
from pyinfra.operations import server, files, systemd
SUDO = True
@ -45,6 +45,28 @@ if not host.fact.command('zpool list local | grep local || true'):
commands=['zpool create -o ashift=12 -o autotrim=on -O encryption=aes-256-gcm -O keylocation=file:///etc/zfs.key -O keyformat=passphrase -O acltype=posixacl -O canmount=off -O dedup=on -O compression=lz4 -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa local mirror /dev/disk/by-id/ata-ST33000650NS_Z290FDG2-part4 /dev/disk/by-id/ata-ST33000650NS_Z290FEJQ-part4 cache /dev/disk/by-id/ata-INTEL_SSDSC2CW240A3_CVCV306301L3240CGN-part2']
)
files.put(
name='Upload systemd zfs-load-key service',
src='files/zfs-load-key.service',
dest='/etc/systemd/system/zfs-load-key.service',
user='root',
group='root',
mode='644',
)
systemd.daemon_reload(
name='Reload systemd',
user_mode=False,
)
systemd.service(
name='Enable zfs-load-key service',
service='zfs-load-key.service',
enabled=True,
restarted=False,
running=False,
)
files.put(
name='Upload LXD config',
src='files/lxd.yml',
@ -83,9 +105,3 @@ if not host.fact.command('zfs list | grep exports || true'):
name='Create ZFS volume exports',
commands=['zfs create local/exports -o mountpoint=/var/backups/lxd']
)
files.line(
name='Add info to motd',
path='/etc/motd',
line='`zfs load-key -a && systemctl start snap.lxd.daemon.service',
)