regexp is not working in window ansible

Hi all,

I would like add a line in particular line, I have written a task as below;

Hi all,

I would like add a line in particular line, I have written a task as below;

---
- name: adding script line with package name
win_lineinfile:
dest: D:/Software/configurations/uCMDBProbeResponseFile.txt
regexp: '^USER_INSTALL_DIR= '
line: 'USER_INSTALL_DIR= F:\\UCMDB\\UCMDBServer'
state: present

But it will add the line in end of the file.
" regexp" is not working it's not able to find the line.
Could you please help me how to fix this issue.

Hello Venkat,

which line do you have in the file that is supposed to match your regular expression?

Regards
         Racke

Hi Racke,

Line “USER_INSTALL_DIR” is exits in the file, Trying to match the line and add new line in same where it will match.

My issue is it’s not matching new line will add end of file.
Can you provide me suggestion any other method to fix this issue ?

Hi Racke,

Line "USER_INSTALL_DIR" is exits in the file, Trying to match the line and add new line in same where it will match.

My issue is it's not matching new line will add end of file.
Can you provide me suggestion any other method to fix this issue ?

What's the *exact line* in your file. You are trying to match on '^USER_INSTALL_DIR= ', so the equal sign *and* the
white space are significant. I would remove the white space from your regular expression as I don't think it has to
be present.

Regards
         Racke

the exact line is “USER_INSTALL_DIR= E:\UCMDB\DataFlowProbe” I wanted to change as like"USER_INSTALL_DIR= F:\UCMDB\UCMDBServer"
There is no white space. this is not adding exact line.