Append {{item}} to existing line

I need to update the grub.conf, for example, with some custom parameters. The kernel line in the grub.conf will vary on each server; therefore, I just wish to append to the line if it doesn’t already contain the parameter. Can this appending be done with lineinfile or some other module? Any examples?

Turns out someone already did this. You can do it with a monster regexp, which I wont even to pretend to understand.

I found out someone had exactly what I needed on ansible-galaxy. I downloaded it and call the role. WORKS PERFECTLY!
https://galaxy.ansible.com/jtyr/grub_cmdline/

I should also note that if going the regexp route you need backrefs enabled (for lineinfile)