diff --git a/roles/lvm_snapshots/tasks/revert.yml b/roles/lvm_snapshots/tasks/revert.yml index 8cdd8dd..6e2ad98 100644 --- a/roles/lvm_snapshots/tasks/revert.yml +++ b/roles/lvm_snapshots/tasks/revert.yml @@ -30,6 +30,24 @@ state: absent when: lvm_snapshots_boot_backup +- name: Check if /boot is on LVM + ansible.builtin.command: "grub2-probe --target=abstraction /boot" + changed_when: false + failed_when: false + register: boot_abstraction + +- name: Reinstall Grub to boot device + when: boot_abstraction.stdout == 'lvm' + block: + - name: Get boot device + ansible.builtin.shell: "lsblk -spnlo name $(grub2-probe --target=device /boot)" + changed_when: false + register: boot_dev_deps + + - name: Run grub2-install + ansible.builtin.command: "grub2-install {{ boot_dev_deps.stdout_lines | last }}" + changed_when: true + - name: Wait for the snapshot to drain ansible.builtin.command: "lvs --select 'vg_name = {{ item.vg_name }} && lv_name = {{ item.origin }}' --reportformat json" register: _lv_drain_check