仅从特定行替换字符串,而通过ansible在多行中出现字符串

当前我的/ etc / default / grub看起来像这样:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet selinux=0 idle=poll isolcpus=2-4 intel_idle.max_cstate=1 nosoftlookup nohalt nmi_watchdog=0"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_CMDLINE_LINUX=$GRUB_CMDLINE_LINUX" net.ifnames=0 biosdevname=0"
GRUB_CMDLINE_LINUX=$GRUB_CMDLINE_LINUX" isolcpus=2-4"

我只需要从第6行中删除isolcpus = 2-4,但最后一行应保持原样。到目前为止,我一直无法做到这一点。我曾经尝试过将其从这两行中删除。 只需要通过ansible来做。

编辑:预期的输出应类似于:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet selinux=0 idle=poll  intel_idle.max_cstate=1 nosoftlookup nohalt nmi_watchdog=0"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_CMDLINE_LINUX=$GRUB_CMDLINE_LINUX" net.ifnames=0 biosdevname=0"
GRUB_CMDLINE_LINUX=$GRUB_CMDLINE_LINUX" isolcpus=2-4"