On 15/05/18 18:23, Padmesh Singh wrote:
> I need help in updating /etc/grub.conf file to disable THP in Linux servers. 
> I used below Ansible lineinfile module but it updates the kernel line 
> everytime when I run it, I need which runs and updates every line of kernel 
> in /etc/fstab file. Please suggest.
> 
> name: disable THP (RedHat)
>   lineinfile: dest=/boot/grub/grub.conf
>   backup=True
>   backrefs=True
>   state=present
>   regexp='(^\s+kernel(\s+(?!transparent_hugepage=never)[\w=/\-\.\,\_]+)*)\s*$'
>   line='\1 transparent_hugepage=never'
> 
> Each time I run the play it will add "transparent_hugepage=never" to a single 
> line where it is not found, instead of every line that starts with kernel. 
> Please suggest how to update this string in all the line that starts with 
> Kernel. 

Perhaps you want 'replace' rather than 'lineinfile'? Being careful that
your regexp doesn't match the line if it's already correct.

Richard

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6e014edd-9fe0-bd8b-70f4-59e200699850%40walnut.gen.nz.
For more options, visit https://groups.google.com/d/optout.

Reply via email to