I tried the regexp=“[1]kernel*\n$”, but ansible cannot detect the kernel line, the regexp=“[2]kernel” did not work either. No luck for lineinfile module either. What I could be missing here? Appreciate any clues.
You are right, it works if I don’t use with_items (something wrong with my following statement). Anyway, the problem now is that rdblacklist=nouveau nouveau.modeset=0 is inserted to the end of file, not the kernel end of line. Is there any way to insert parameters to end of line, or it is impossible to insert things at the end of line in ansible? Sorry, I might have to post in another subject.
name “Insert nouveau at the end of the kernel line”
lineinfile: dest=/boot/grub/grub.conf state=present backrefs=True regexp=“{{ item.regexp }}” line=“{{ item.insert }}”
with_items: