How to Ansible copy force overwrite

Hi everyone,

i m trying to copy file. But win_copy doesn’t copy overwrite. How can I overcome this error? is there a way to get around this?

my code>>>

  • name: Copy a single file where the source is on the remote host
    win_copy:
    src: C:\Tools\AWXtest\New folder\autounattend.xml
    dest: E:\OtomasyonFiles\WINDOWSISO\win2019
    remote_src: yes

Error: “msg”: "cannot copy file from ‘C:\Tools\AWXtest\New folder\autounattend.xml’ to ‘E:\OtomasyonFiles\WINDOWSISO\win2019’: dest is already a folder

https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_copy_module.html#parameter-force

The problem here is you are telling it to copy the file to the location E:\OtomasyonFiles\WINDOWSISO\win2019 which is a folder. Add a trailing \ to the dest or use the full path to where you want the file to be (‘E:\OtomasyonFiles\WINDOWSISO\win2019\autounattend.xml’) so it knows to place the file in the folder rather than the folder itself.