From fa13f78271c0bb05da6d942c748eb813fea5ac8a Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Mon, 5 Dec 2022 22:21:07 +0100 Subject: [PATCH] Do not hardcode hpool in load-key --- ...fs-load-key-hpool.service => zfs-load-key@.service} | 4 ++-- plays/roles/system_zfs/tasks/include/load_key.yml | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) rename plays/roles/system_zfs/files/load_key/{zfs-load-key-hpool.service => zfs-load-key@.service} (77%) diff --git a/plays/roles/system_zfs/files/load_key/zfs-load-key-hpool.service b/plays/roles/system_zfs/files/load_key/zfs-load-key@.service similarity index 77% rename from plays/roles/system_zfs/files/load_key/zfs-load-key-hpool.service rename to plays/roles/system_zfs/files/load_key/zfs-load-key@.service index 0eda6b5..04c5e93 100644 --- a/plays/roles/system_zfs/files/load_key/zfs-load-key-hpool.service +++ b/plays/roles/system_zfs/files/load_key/zfs-load-key@.service @@ -1,5 +1,5 @@ [Unit] -Description=Load encryption key for ZFS hpool +Description=Load encryption key for a ZFS pool Documentation=man:zfs(8) DefaultDependencies=no After=systemd-udev-settle.service @@ -11,7 +11,7 @@ ConditionPathIsDirectory=/sys/module/zfs [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/sbin/zfs load-key hpool +ExecStart=/sbin/zfs load-key %i [Install] WantedBy=zfs.target diff --git a/plays/roles/system_zfs/tasks/include/load_key.yml b/plays/roles/system_zfs/tasks/include/load_key.yml index cff3460..db229d6 100644 --- a/plays/roles/system_zfs/tasks/include/load_key.yml +++ b/plays/roles/system_zfs/tasks/include/load_key.yml @@ -1,9 +1,7 @@ -# TODO: drop file dependence on hpool. - - name: "load_key : zfs load key service file" ansible.builtin.copy: - src: "./load_key/zfs-load-key-hpool.service" - dest: "/etc/systemd/system/zfs-load-key-hpool.service" + src: "./load_key/zfs-load-key@.service" + dest: "/etc/systemd/system/zfs-load-key@.service" mode: 0644 register: systemd_zfs_load_key_service_file @@ -13,8 +11,8 @@ when: 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: - name: "zfs-load-key-hpool.service" + name: "zfs-load-key@{{ item }}.service" enabled: true loop: "{{ zpools_load_key }}"