Lineinfile creates duplicates entries when running playbook multiple times

238 views
Skip to first unread message

janaki raman

unread,
Mar 22, 2021, 12:07:08 AM3/22/21
to Ansible Development

Hi All,

 lineinfile duplicates the entry... I am trying to append a line based on the regex... but if i run the playbook again, it keeps adding the lines...

- name: "Updating /etc/default/grub with security parameters"
     lineinfile:
       path: /etc/default/grub_new
       backrefs: yes
       state: present
       regexp: '(^GRUB_CMDLINE_LINUX_DEFAULT=.*)$'
       line: '\1\nnuma_balancing=disable'


I tried the same with replace module, still got the same result.. Not sure what am i missing here

Per Hjartoy

unread,
Mar 22, 2021, 12:43:14 AM3/22/21
to Ansible Development
Try taking our the \n. I have just had a similar problem with blockinfile. Last I checked, there is an open bug for the issue.
--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/0cfe076a-49ce-4332-9f96-21821afd3c3cn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages