Strange backslash quote issue

166 views
Skip to first unread message

Doug Eubanks

unread,
Feb 24, 2015, 3:06:18 PM2/24/15
to ansible...@googlegroups.com
Hello:

This:
    - name: reconfigure suexec path in httpd spec
      lineinfile: dest=/root/rpmbuild/SPECS/httpd.spec regexp='^.*--with-suexec-docroot=.*' line='        --with-suexec-docroot=/home \' insertafter='^.*--with-suexec-caller=.*'
      when: suexec_output|changed

Is throwing this error:
ERROR: There was an error while parsing the task "lineinfile dest=/root/rpmbuild/SPECS/httpd.spec regexp='^.*--with-suexec-docroot=.*' line='        --with-suexec-docroot=/home \\' insertafter='^.*--with-suexec-caller=.*'".
Make sure quotes are matched or escaped properly

I've tried escaping the backslash, using single quotes, double quotes, and I just can't find the right combination.  I need it to use literal string below, including the backslash.
--with-suexec-docroot=/home \

Whats the correct syntax for this?

Doug

Damian Lubosch

unread,
Jun 24, 2015, 3:37:52 PM6/24/15
to ansible...@googlegroups.com
Hi,

I have exactly the same issue.
In lineinfile module adding backslashes at the end of a line leads to an error:

ERROR: There was an error while parsing the task 'lineinfile dest=/root/rpmbuild/SPECS/nginx.spec insertafter=".*--with-http_mp4_module.*" line=\'        --with-http_image_filter_module \\\\\''.
Make sure quotes are matched or escaped properly
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
FAIL: 1

My provisory solution for this is to add a backslash and space at the end of the to be added line and to remove the additional space with sed:

- name: enable --with-http_image_filter_module
  lineinfile: dest=/root/rpmbuild/SPECS/nginx.spec insertafter=".*--with-http_mp4_module " line="        --with-http_image_filter_module \ "

- name: fix for trailing backslash
  command: sed -i 's/\\ /\\/g' /root/rpmbuild/SPECS/nginx.spec

Anyway, using 

line="blablabla \\" 

should lead to the text
blablabla \

without any spaces etc. Where can I ask for this to be added?

Cheers,
Damian
Reply all
Reply to author
Forward
0 new messages