role.grub_add_cmdlineparameter/tasks/parameter.yml

22 lines
578 B
YAML
Raw Permalink Normal View History

2024-03-12 20:27:26 +00:00
---
- name: "Look for parameter {{ item.key }}"
ansible.builtin.shell:
cmd: 'grep "^GRUB_CMDLINE_LINUX=.*{{ item.key }}={{ item.value }}" /etc/default/grub || true'
changed_when: False
register: grub_cmdline_find_param
- name: "Add {{ item.key }}={{ item.value }}"
ansible.builtin.lineinfile:
path: /etc/default/grub
line: 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} {{ item.key }}={{ item.value }}"'
insertafter: '^GRUB_CMDLINE_LINUX='
owner: root
group: root
mode: 0644
backup: yes
notify:
- "update-grub for cmdlineparameter"