Do not hardcode hpool in load-key

This commit is contained in:
Wojciech Kozlowski 2022-12-05 22:21:07 +01:00
parent afd3e44618
commit fa13f78271
2 changed files with 6 additions and 8 deletions

View File

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Load encryption key for ZFS hpool Description=Load encryption key for a ZFS pool
Documentation=man:zfs(8) Documentation=man:zfs(8)
DefaultDependencies=no DefaultDependencies=no
After=systemd-udev-settle.service After=systemd-udev-settle.service
@ -11,7 +11,7 @@ ConditionPathIsDirectory=/sys/module/zfs
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecStart=/sbin/zfs load-key hpool ExecStart=/sbin/zfs load-key %i
[Install] [Install]
WantedBy=zfs.target WantedBy=zfs.target

View File

@ -1,9 +1,7 @@
# TODO: drop file dependence on hpool.
- name: "load_key : zfs load key service file" - name: "load_key : zfs load key service file"
ansible.builtin.copy: ansible.builtin.copy:
src: "./load_key/zfs-load-key-hpool.service" src: "./load_key/zfs-load-key@.service"
dest: "/etc/systemd/system/zfs-load-key-hpool.service" dest: "/etc/systemd/system/zfs-load-key@.service"
mode: 0644 mode: 0644
register: systemd_zfs_load_key_service_file register: systemd_zfs_load_key_service_file
@ -13,8 +11,8 @@
when: when:
systemd_zfs_load_key_service_file.changed systemd_zfs_load_key_service_file.changed
- name: "load_key : enable service to load for {{ item }}" - name: "load_key : enable service to load key for {{ item }}"
ansible.builtin.systemd: ansible.builtin.systemd:
name: "zfs-load-key-hpool.service" name: "zfs-load-key@{{ item }}.service"
enabled: true enabled: true
loop: "{{ zpools_load_key }}" loop: "{{ zpools_load_key }}"