lineinfile with a backslash in the regexp field

17 views
Skip to first unread message

fanvalt

unread,
Jun 28, 2016, 10:01:23 AM6/28/16
to Ansible Project
Hello,

I would like to replace the following line:
jstl.jar,taglibs-standard-spec-*.jar,\
with:
jstl.jar,taglibs-standard-spec-*.jar,icu4j-2.6.1.jar,\

I tried to double the backslash without any success, the issue occurs only on the regexp backslash:

For example, when doing this:
- name: catalina.properties jstl
  lineinfile:
    dest: /{{ tomcatdir }}/conf/catalina.properties
    regexp: "^jstl.jar,taglibs-standard-spec-*.jar,.*"
    line: "jstl.jar,taglibs-standard-spec-*.jar,icu4j-2.6.1.jar,\\"

I have no error but an extra line as it does not recognize the line to replace, I thought '.' was meaning any character and '*' as many as we want.
When using this one:
    regexp: "^jstl.jar,taglibs-standard-spec-*.jar,\\"
    line: "jstl.jar,taglibs-standard-spec-*.jar,icu4j-2.6.1.jar,\\"

I have a syntax error.

Can you help me about using the backslash in the regexp parameter, without being a special character ?

Regards
Reply all
Reply to author
Forward
0 new messages