Set GRUB_DEFAULT by kernel version

31 views
Skip to first unread message

jabb degen

unread,
Jul 9, 2020, 9:00:59 AM7/9/20
to Ansible Development
Hey guys,
I want  set the GRUB_DEFAULT Variable accordingly to a specified kernel version. I'm not quite sure how to do it in an ansible clean way.

Pseudo code which explains the desired task
-----------------------
var kernelversion="5.0.3"

// file: /boot/grub/grub.cfg
parse_grub_cfg(kernelversion){
return(entry)
// entry=2>1 or 3>2, ....
}

file: /etc/default/grub
set_grub(entry)
-------------------------------


How can I achieve the task?

Solution A)
write an complete own module which parses the /boot/grub/grub.cfg file and than edits the /etc/default/grub file

Solution B)
write a custom fact. The custom fact sets the correct entry as new ansible variable than call the liniefile module to edit the /etc/default/grub file

Solution C)
call the script module with the parsing script

Solution D)
something complete different

Attached is the script for parsing the /boot/grub/grub.cfg

func
Reply all
Reply to author
Forward
0 new messages