Replace a string in multiple lines in a file not working

Hi all,
I’m written a play book to replace a string in multiple lines in a file but it not reflected, It has changed in last line of a file.
not replace in multiple places.

  • name: updating driver letter as in config file
    win_lineinfile:
    path: “{{ item.path }}”
    backrefs: true
    regexp: ‘-fileOverwrite_D’
    line: ‘-fileOverwrite_{{ target_disk|upper }}’
    state: present
    with_items:
  • “{{ result.files }}”

The file of content is as below:

install

Hi Venkat,

Use replace instead of line. Replace will substitute all instances of regexp.

See example below:


- name: Replace after the expression till the end of the file (requires Ansible >= 2.4)
  replace:
    path: /etc/apache2/sites-available/default.conf
    after: 'NameVirtualHost [*]'
    regexp: '^(.+)$'
    replace: '# '

Thanks for reply.
I’m working on windows so it’s not working “replace module”

Thanks for reply.
I'm working on windows so it's not working "replace module"

Why wouldn't the module work on Windows?

Regards
         Racke

All modules not supporting for windows.

see below link for windows for window;
https://docs.ansible.com/ansible/latest/modules/list_of_windows_modules.html

All modules not supporting for windows.

see below link for windows for window;
https://docs.ansible.com/ansible/latest/modules/list_of_windows_modules.html

I would assume that all regular Ansible modules work with Windows unless specifically noted in
the module documentation.

Regards
        Racke

Ansible is easy in linux but not easy in windows.