From 41119cb98963696db7f69969a7b31d331b702287 Mon Sep 17 00:00:00 2001 From: Bob Mader Date: Fri, 10 Nov 2023 13:51:30 -0600 Subject: [PATCH 1/4] force grubenv saved_entry --- roles/lvm_snapshots/tasks/create.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/lvm_snapshots/tasks/create.yml b/roles/lvm_snapshots/tasks/create.yml index 224d45e..2a47187 100644 --- a/roles/lvm_snapshots/tasks/create.yml +++ b/roles/lvm_snapshots/tasks/create.yml @@ -18,6 +18,9 @@ changed_when: true when: ((lvm_snapshots_new_lvm_config | trim) | length) > 0 +- name: Force grubenv saved_entry + ansible.builtin.shell: 'grubby --set-default-index=$(grubby --default-index)' + - name: Create snapshots community.general.lvol: vg: "{{ item.vg }}" From 7af5764c28d14ad7be4eb58ff3f4e27201ad4156 Mon Sep 17 00:00:00 2001 From: Bob Mader Date: Mon, 13 Nov 2023 13:09:23 -0600 Subject: [PATCH 2/4] 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: From 0023a233aa3dfbaccfbc5e78721e0b20d5903b83 Mon Sep 17 00:00:00 2001 From: Bob Mader Date: Mon, 13 Nov 2023 13:24:35 -0600 Subject: [PATCH 3/4] use fqcn --- roles/lvm_snapshots/tasks/create.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/lvm_snapshots/tasks/create.yml b/roles/lvm_snapshots/tasks/create.yml index 769eb59..ec5b55d 100644 --- a/roles/lvm_snapshots/tasks/create.yml +++ b/roles/lvm_snapshots/tasks/create.yml @@ -19,7 +19,7 @@ when: ((lvm_snapshots_new_lvm_config | trim) | length) > 0 - name: Check for grubenv saved_entry - lineinfile: + ansible.builtin.lineinfile: name: /boot/grub2/grubenv regexp: ^saved_entry= state: absent From a313b540d3828c21dfe7d27b3fe9f5b553233d01 Mon Sep 17 00:00:00 2001 From: Bob Mader Date: Mon, 13 Nov 2023 13:31:44 -0600 Subject: [PATCH 4/4] fix no-changed-when --- roles/lvm_snapshots/tasks/create.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/lvm_snapshots/tasks/create.yml b/roles/lvm_snapshots/tasks/create.yml index ec5b55d..55561d1 100644 --- a/roles/lvm_snapshots/tasks/create.yml +++ b/roles/lvm_snapshots/tasks/create.yml @@ -30,6 +30,7 @@ - name: Add grubenv saved_entry ansible.builtin.shell: 'grubby --set-default-index=$(grubby --default-index)' + changed_when: true when: grubenv.found is defined and grubenv.found == 0 - name: Create snapshots