I'm learning Ansible for a new project, and I'm stuck on what looks like a basic issue.
Using lineinfile with backrefs and \1 doesn't work for me.
Simplified playbook to comment out a line starting with "This":
---
- hosts: localhost
tasks:
- name: comment out This
lineinfile: dest=test.txt backrefs=yes regexp='^This.*' line='#\\1'
test.txt file:
Nothing special
This is a test
Nothing special
Result of: "ansible-playbook edit5.yml"
Nothing special
#\
Nothing special
I've tried single, double, 4 \'s. Single \ gives an error "invalid group reference". 3 gives "#\1", 4 gives "#\" again.
I've been googling for an answer, but all the excerpts I see give similar results. Other characters other than # work the same.
I am running Ansible 1.9.4 on RHEL 6.7. I also tried replace: with similar results.
Thank you!
Boyd