Hi, I would like to append a parameter "transparent_hugepage=never" to the below regex matched line in-between the quotes. On subsequent runs the substitution should be ignored to maintain idempotence (run as an Ansible playbook task). I tried a few things but failed as my knowledge is very limited. Thank you for your help and pardon my poor articulation. Line in question:
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"The sed keeps appending after repeating the play as I can't get the negative lookahead assertion to work, I think that's what it is?
sed '/^GRUB_CMDLINE_LINUX=.*/ s/\(.*\)"/\1 transparent_hugepage=never"/' $lineAnd this from the playbook appends after the last quote breaking the config:
+ replace: + backup: yes + dest: /etc/default/grub + regexp: '(^GRUB_CMDLINE_LINUX(?!.*\btransparent_hugepage=never\b).*)$' + replace: '\1 transparent_hugepage=never"'
In reply to GRUB Append Parameter in-between Quotes by ephemeric
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |