Need support for a task using lineinfile module

Hello,
I am trying to replace the line
${sys:com.ibm.ssc.logPath:-ssc_logs}
with
/app/IBM/logs/SSC
using replace & lineinfile modules. But it doesn’t work as expected.

Playbook

  • name: Check line present or not
    shell: grep ‘^${sys:com.ibm.ssc.logPath:-ssc_logs}’ /app/IBM/SSC/log4j2.xml
    register: grep_output
  • name: Replace a line with special characters
    lineinfile:
    path: /app/IBM/SSC/log4j2.xml
    regexp: ‘^${sys:com.ibm.ssc.logPath:-ssc_logs}’
    line: ‘/app/IBM/logs/SSC’
    backrefs: no
    when: grep_output.rc == 0

The first task with shell module works fine but second one adds a new line at bottom of the file, instead of replacing it.
I did try adding state=absent argument in the second task, but still no luck. Could you suggest. Thanks!

Hi,
On which lab did you experience this issue?

It is not related to the lab. I am trying to implement lineinfile/replace modules at my work place.

I am doing the conditionals lab, and having an issue on the last question trying to use the lineinfile module, I keep getting Error 16, file busy…