ephemeric has asked for the wisdom of the Perl Monks concerning the following question:
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"'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GRUB Append Parameter in-between Quotes
by shmem (Chancellor) on Sep 09, 2016 at 18:48 UTC | |
by stevieb (Canon) on Sep 10, 2016 at 00:37 UTC | |
by ephemeric (Novice) on Sep 12, 2016 at 07:55 UTC | |
|
Re: GRUB Append Parameter in-between Quotes
by neilwatson (Priest) on Sep 09, 2016 at 18:48 UTC | |
by ephemeric (Novice) on Sep 12, 2016 at 07:50 UTC | |
by hippo (Archbishop) on Sep 12, 2016 at 08:12 UTC | |
by ephemeric (Novice) on Sep 20, 2016 at 09:33 UTC | |
|
Re: GRUB Append Parameter in-between Quotes
by haukex (Archbishop) on Sep 13, 2016 at 15:36 UTC | |
by ephemeric (Novice) on Sep 20, 2016 at 09:34 UTC |