From 7af5764c28d14ad7be4eb58ff3f4e27201ad4156 Mon Sep 17 00:00:00 2001 From: Bob Mader Date: Mon, 13 Nov 2023 13:09:23 -0600 Subject: [PATCH] don't touch grubenv unless needed --- roles/lvm_snapshots/tasks/create.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/roles/lvm_snapshots/tasks/create.yml b/roles/lvm_snapshots/tasks/create.yml index 2a47187..769eb59 100644 --- a/roles/lvm_snapshots/tasks/create.yml +++ b/roles/lvm_snapshots/tasks/create.yml @@ -18,8 +18,19 @@ changed_when: true when: ((lvm_snapshots_new_lvm_config | trim) | length) > 0 -- name: Force grubenv saved_entry +- name: Check for grubenv saved_entry + lineinfile: + name: /boot/grub2/grubenv + regexp: ^saved_entry= + state: absent + check_mode: true + changed_when: false + failed_when: false + register: grubenv + +- name: Add grubenv saved_entry ansible.builtin.shell: 'grubby --set-default-index=$(grubby --default-index)' + when: grubenv.found is defined and grubenv.found == 0 - name: Create snapshots community.general.lvol: