lineinfile: backrefs and jinja2 variables

310 views
Skip to first unread message

Gregor Giesen

unread,
May 30, 2014, 4:58:53 AM5/30/14
to ansible...@googlegroups.com
Hi everybody,

when I try the following in a playbook (ansible 1.6.2):

- lineinfile:
    dest: /etc/nagios/nrpe.cfg
    backrefs: yes
    regexp: '^(allowed_hosts=).*$'
    line: '\1{{ monitoring_server }}'

where "monitoring_server=10.0.0.5", it replaces the line "allowed_hosts=127.0.0.1" with "H.0.0.5".
If I put any character between "\1" and "{{", it seems to be working correctly, but I don't want an additional character there.

Thanks and best regards,
Gregor

Michael DeHaan

unread,
May 31, 2014, 12:21:06 PM5/31/14
to ansible...@googlegroups.com
lineinfile can be tricky and most times I'd discourage usage of it in favor of the template module.

However, in this case, this feels like a bug report to me.   Please be sure to file one on github.


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/185ab4d1-de45-42a8-a138-a843d6499107%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gregor Giesen

unread,
May 31, 2014, 4:40:02 PM5/31/14
to ansible...@googlegroups.com

However, in this case, this feels like a bug report to me.   Please be sure to file one on github.
Reply all
Reply to author
Forward
0 new messages