Skip to content

Commit

Permalink
reinstall grub if lvm
Browse files Browse the repository at this point in the history
  • Loading branch information
swapdisk committed Nov 14, 2023
1 parent 244e3f4 commit 5b1403a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions roles/lvm_snapshots/tasks/revert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5b1403a

Please sign in to comment.