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!