regexp is not working in window ansible

80 views
Skip to first unread message

Uppara venkat

unread,
Dec 17, 2019, 12:06:52 PM12/17/19
to ansible...@googlegroups.com
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.
    


Thanks& Regards,
Venkat

Stefan Hornburg (Racke)

unread,
Dec 17, 2019, 4:15:32 PM12/17/19
to ansible...@googlegroups.com
Hello Venkat,

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

>
>
> Thanks& Regards,
> Venkat
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFMhZ_LD13JKfKAS8GrU%2B7MCAd8hXPubejmRh8WemT2fRuFg6w%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAFMhZ_LD13JKfKAS8GrU%2B7MCAd8hXPubejmRh8WemT2fRuFg6w%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Uppara venkat

unread,
Dec 17, 2019, 11:41:18 PM12/17/19
to ansible...@googlegroups.com
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 ?


To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1b93acc9-b8c4-4055-46d7-f6c0ab96dcb9%40linuxia.de.


--






Thanks& Regards,
venkatesulu.U
8147041026

Stefan Hornburg (Racke)

unread,
Dec 18, 2019, 2:54:57 AM12/18/19
to ansible...@googlegroups.com
On 12/18/19 5:40 AM, Uppara venkat wrote:
> 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

>
> On Wed, Dec 18, 2019 at 2:45 AM Stefan Hornburg (Racke) <ra...@linuxia.de <mailto:ra...@linuxia.de>> wrote:
>
> On 12/17/19 6:06 PM, Uppara venkat wrote:
> > 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
>
> >
> >
> > Thanks& Regards,
> > Venkat
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to
> > ansible-proje...@googlegroups.com <mailto:ansible-project%2Bunsu...@googlegroups.com>
> <mailto:ansible-proje...@googlegroups.com <mailto:ansible-project%2Bunsu...@googlegroups.com>>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/CAFMhZ_LD13JKfKAS8GrU%2B7MCAd8hXPubejmRh8WemT2fRuFg6w%40mail.gmail.com
> >
> <https://groups.google.com/d/msgid/ansible-project/CAFMhZ_LD13JKfKAS8GrU%2B7MCAd8hXPubejmRh8WemT2fRuFg6w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-project%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFMhZ_KvOr%2BQdOxP2F_OicDsWnJKPu-PCmYA9ikXESkfbf3Ftg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAFMhZ_KvOr%2BQdOxP2F_OicDsWnJKPu-PCmYA9ikXESkfbf3Ftg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
signature.asc

Uppara venkat

unread,
Dec 18, 2019, 3:16:02 AM12/18/19
to ansible...@googlegroups.com
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. 


To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d45e8ca7-4177-edd0-f1a8-a645cab6954c%40linuxia.de.
Reply all
Reply to author
Forward
0 new messages