Skip to content

Commit

Permalink
Fix lvm grub (#23)
Browse files Browse the repository at this point in the history
* reinstall Grub if /boot on LVM

* changelog
  • Loading branch information
swapdisk committed Nov 14, 2023
1 parent 244e3f4 commit 449840a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/fix-lvm-grub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Grub needs reinstall if /boot is on LVM
18 changes: 18 additions & 0 deletions roles/lvm_snapshots/tasks/revert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@
- name: Reboot
ansible.builtin.reboot:

- 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: Remove boot backup
ansible.builtin.file:
path: "/root/boot-backup-{{ lvm_snapshots_set_name }}.tgz"
Expand Down

0 comments on commit 449840a

Please sign in to comment.