Problem copying a file from a network drive to a another directory (Windows 10)

23 views
Skip to first unread message

Roni Warken

unread,
May 8, 2020, 12:36:36 PM5/8/20
to Ansible Project
Hi all.

As a beginner, one of the first playbooks I am developing is to copy a file from a network drive to the windows host.

[warken1@ansible-controller windows-projects]$ ansible --version
ansible
2.9.7
  config file
= /etc/ansible/ansible.cfg
  configured
module search path = ['/home/warken1/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python
module location = /usr/lib/python3.6/site-packages/ansible
  executable location
= /usr/bin/ansible
  python version
= 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]


The playbook file_TU_copy.yml:

---

- name: Copying a file to Windows host
  gather_facts
: no
  hosts
: win
  tasks
:
   
- name: Copy TU.exe file
      win_copy
:
        src
: 'Z:\TU\TestUniverseLabel.png'
        remote_src
: yes
        dest
: 'C:\TU\TestUniverseLabel.png'

The error returning is this:

[warken1@ansible-controller windows-projects]$ ansible-playbook -i inventory file_TU_copy.yml

PLAY
[Copying a file to Windows host] ********************************************************************************************

TASK
[Copy TU.exe file] **********************************************************************************************************
fatal
: [win-node1]: FAILED! => {"changed": false, "dest": "C:\\TU\\TestUniverseLabel.png", "msg": "Cannot copy src file: 'Z:\\TU\\TestUniverseLabel.png' as it does not exist", "src": "Z:\\TU\\TestUniverseLabel.png"}

PLAY RECAP
***********************************************************************************************************************
win
-node1                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  


Some details about the "infrastructure" behind this :) Both ansible and windows hosts are VMs available in a VMware Workstation. I shared a host folder (this is the network drive), so the windows VM has access to it. I can copy, move, delete, etc files from inside the windows VM. Not sure if that is something to consider thou related to the ansible VM...

Any light over my brain is really appreciated for my next steps.

Jordan Borean

unread,
May 8, 2020, 2:38:18 PM5/8/20
to Ansible Project
You cannot access mapped drives through WinRM. You need to use the full UNC path. Also you need to be aware of the credential delegation problem when accessing network paths when using WinRM. You can connect with CredSSP, or Kerberos with delegation or use become on the task to bypass that.
Reply all
Reply to author
Forward
0 new messages