Skip to content

Commit fd638b7

Browse files
authored
Merge pull request #13976 from jan-cerny/grub2_argument_absent
Make Ansible in grub2_argument_absent template idempotent
2 parents 8cde796 + 9bc25e4 commit fd638b7

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
@@ -1578,8 +1578,21 @@ Part of the grub2_bootloader_argument_absent template.
15781578
- name: Update grub defaults and the bootloader menu
15791579
ansible.builtin.command: /usr/sbin/update-grub
15801580
{{% else %}}
1581+
- name: Check if {{{ arg_name }}} argument is already present in /etc/default/grub
1582+
ansible.builtin.slurp:
1583+
src: /etc/default/grub
1584+
register: etc_default_grub
1585+
1586+
- name: Check if {{{ arg_name }}} argument is present
1587+
ansible.builtin.command: /sbin/grubby --info=ALL
1588+
register: grubby_info
1589+
check_mode: False
1590+
changed_when: False
1591+
failed_when: False
1592+
15811593
- name: Update grub defaults and the bootloader menu
15821594
ansible.builtin.command: /sbin/grubby --update-kernel=ALL --remove-args="{{{ arg_name }}}"
1595+
when: (grubby_info.stdout is search('{{{ arg_name }}}')) or ((etc_default_grub['content'] | b64decode) is search('{{{ arg_name }}}'))
15831596
{{% endif -%}}
15841597
{{%- endmacro -%}}
15851598

0 commit comments

Comments
 (0)