Skip to content

Commit cccef24

Browse files
authored
Merge pull request #13957 from jan-cerny/grub2_bootloader_argument
Make Ansible in GRUB rules idempotent
2 parents 1bd7235 + 4658b62 commit cccef24

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

shared/macros/10-ansible.jinja

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,8 +1527,21 @@ Part of the grub2_bootloader_argument template.
15271527
- name: Update grub defaults and the bootloader menu
15281528
ansible.builtin.command: /usr/sbin/update-grub
15291529
{{% else %}}
1530+
- name: Check if {{{ arg_name }}} argument is already present in /etc/default/grub
1531+
ansible.builtin.slurp:
1532+
src: /etc/default/grub
1533+
register: etc_default_grub
1534+
1535+
- name: Check if {{{ arg_name }}} argument is already present
1536+
ansible.builtin.command: /sbin/grubby --info=ALL
1537+
register: grubby_info
1538+
check_mode: False
1539+
changed_when: False
1540+
failed_when: False
1541+
15301542
- name: Update grub defaults and the bootloader menu
15311543
ansible.builtin.command: /sbin/grubby --update-kernel=ALL --args="{{{ arg_name_value }}}"
1544+
when: (grubby_info.stdout is not search('{{{ arg_name_value }}}')) or ((etc_default_grub['content'] | b64decode) is not search('{{{ arg_name_value }}}'))
15321545
{{% endif -%}}
15331546
{{%- endmacro -%}}
15341547

0 commit comments

Comments
 (0)