Strange backslash quote issue

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

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