Set GRUB_DEFAULT by kernel version

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

(attachments)

func (902 Bytes)