How to Ansible copy force overwrite

1,159 views
Skip to first unread message

Kerem Kalayci

unread,
Feb 21, 2022, 9:27:33 AM2/21/22
to Ansible Project
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

Dick Visser

unread,
Feb 21, 2022, 10:18:00 AM2/21/22
to ansible...@googlegroups.com

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/86676885-5d56-44be-88d2-52cd6ccd555cn%40googlegroups.com.


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

jbor...@gmail.com

unread,
Feb 21, 2022, 7:23:33 PM2/21/22
to Ansible Project
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.
Reply all
Reply to author
Forward
0 new messages