From 83d52631109bca79e3ca2b0f4c6cbef6b584db28 Mon Sep 17 00:00:00 2001 From: nicobo Date: Mon, 14 Mar 2022 20:57:43 +0100 Subject: [PATCH] Added grub_default_options to define GRUB_CMDLINE_LINUX_DEFAULT --- tasks/main.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index 2b15271..db4477d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -47,5 +47,22 @@ - grub_options is defined - grub_options | length > 0 + +- name: add options to GRUB_CMDLINE_LINUX_DEFAULT + ansible.builtin.replace: + path: /etc/default/grub + regexp: '^GRUB_CMDLINE_LINUX_DEFAULT="((:?(?!{{ item.option }}=?[^s]*).)*?)"$' + replace: 'GRUB_CMDLINE_LINUX_DEFAULT="\1 {{ item.option }}{{ "={}".format(item.value) if item.value is defined else "" }}"' + validate: /bin/sh %s + mode: "0664" + loop: "{{ grub_default_options }}" + loop_control: + label: "{{ item.option }}" + notify: + - update grub + when: + - grub_default_options is defined + - grub_default_options | length > 0 + - name: flush handlers ansible.builtin.meta: flush_handlers