# ansible 2.3 win\_copy fails when trying to get file from network drive

**URL:** <https://forum.ansible.com/t/ansible-2-3-win-copy-fails-when-trying-to-get-file-from-network-drive/24039>\
**Category:** Ansible Project\
**Created:** [March 22, 2017, 11:00pm UTC](https://forum.ansible.com/t/ansible-2-3-win-copy-fails-when-trying-to-get-file-from-network-drive/24039 "2017-03-22T23:00:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick\_korsnick](https://avatars.discourse-cdn.com/v4/letter/p/a6a055/32.png) [@patrick\_korsnick](https://forum.ansible.com/u/patrick_korsnick)\
**Post date:** [March 22, 2017, 11:00pm UTC](https://forum.ansible.com/t/ansible-2-3-win-copy-fails-when-trying-to-get-file-from-network-drive/24039/1 "2017-03-22T23:00:14Z")

</div>

Hi all,

Has anyone had any luck using the new in 2.3 feature of win\_copy (remote\_src) to copy files to/from a mapped network drive?

essentially I’m trying to do this:

- name: copy from share  
win\_copy:  
src: w:\foo  
dest: c:  
remote\_src: True

and I get a message saying the src path doesn’t exist. I tried using a UNC path instead of the drive letter also.

The way I’ve been getting around this is to use a bat file that maps the drive and then does the copy, but I’d like to be able to do it with only the playbook and no bat file.

Thanks for any input!

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [March 23, 2017, 5:30am UTC](https://forum.ansible.com/t/ansible-2-3-win-copy-fails-when-trying-to-get-file-from-network-drive/24039/2 "2017-03-23T05:30:48Z")

</div>

Not tried it yet myself but can you establish if it works for a file that isn’t on a mapped drive first?  
If so then its possible you are getting into a second hop authentication scenario (by default windows doesn’t allow more than a single hop (ansible controller → windows box, but you may have 2 hops here (ansible → windows box → mapped drive on another windows box). There are ways around this (either by using a domain user or credssp). If you are already connecting as a domain user, make sure you are using pywinrm==0.2.0 or later, and add `ansible_winrm_kerberos_delegation=true` to the inventory vars for the Windows host in question.

If CredSSP is an option for you, you’ll need to check your systems meet the requirements (see [http://docs.ansible.com/ansible/intro\_windows.html#credssp](http://docs.ansible.com/ansible/intro_windows.html#credssp) ) install the requests-credssp library on your ansible controller and run the ConfigureForRemoting… script with the EnableCredSSP option as described here: [http://docs.ansible.com/ansible/intro\_windows.html#windows-system-prep](http://docs.ansible.com/ansible/intro_windows.html#windows-system-prep)

Please let us know how you get on.

(oh and thanks for testing 2.3 Release candidate).

Jon

---

<div class="post-metadata">

**Author:** ![patrick\_korsnick](https://avatars.discourse-cdn.com/v4/letter/p/a6a055/32.png) [@patrick\_korsnick](https://forum.ansible.com/u/patrick_korsnick)\
**Post date:** [March 23, 2017, 6:35pm UTC](https://forum.ansible.com/t/ansible-2-3-win-copy-fails-when-trying-to-get-file-from-network-drive/24039/3 "2017-03-23T18:35:03Z")

</div>

Hi Jon,

Thanks for the input. You’re correct about the number of authentication hops- the client machine is not on a domain, but uses domain credentials to map the network share. So in the group\_vars file there are only the non-domain credentials. I was able to use win\_copy to copy a local file to another local file, but even after upgrading pywinrm to 0.2.0 and installing the credssp and re-running the ConfigureRemotingForAnsible.ps1 script on the client with the credssp argument it still doesn’t work. I’m thinking it’s because I need to figure out how to pass it the credentials for the second-hop authentication.

thanks again!  
pat

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [March 23, 2017, 10:53pm UTC](https://forum.ansible.com/t/ansible-2-3-win-copy-fails-when-trying-to-get-file-from-network-drive/24039/4 "2017-03-23T22:53:44Z")

</div>

Hmm. Is adding the client machine to the domain an option then? That way you could use Kerberos authentication delegation.

Or. Here's a different idea...  
Use smbclient to collect whatever files you want from the share onto your ansible controller and then you can just win\_copy them onto the windows targets.

Smbclient will happily work with the domain login for the share, just specify -U username -W domainName

I do something like the above once builds are signed off I collect them onto an ansible controller and then use synchronize to rsync files to ansibles running in other datacenters.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [March 24, 2017, 12:54am UTC](https://forum.ansible.com/t/ansible-2-3-win-copy-fails-when-trying-to-get-file-from-network-drive/24039/5 "2017-03-24T00:54:55Z")

</div>

The new Windows become stuff in 2.3 creates an “interactive” type logon session, so credential caches and transparent multi-hop works- it should take care of the auth issue (so it behaves like it would if you were sitting in front of the machine). There’s currently a bug that only allows it to work under Basic and CredSSP (not NTLM/Kerb), but I’m hoping to have that nailed down by 2.3RC2.

Just do:

- win\_copy:  
… (whatever args to win\_copy)  
become: yes  
become\_method: runas  
become\_user: “{{ ansible\_user }}”  
become\_password: “{{ ansible\_password }}”

This _should_ take care of it for you…

-Matt

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [March 24, 2017, 1:00am UTC](https://forum.ansible.com/t/ansible-2-3-win-copy-fails-when-trying-to-get-file-from-network-drive/24039/6 "2017-03-24T01:00:27Z")

</div>

Sorry, that should’ve been:

- win\_copy:  
… (whatever args to win\_copy)  
become: yes  
become\_method: runas  
become\_user: “{{ ansible\_user }}”  
vars:  
ansible\_become\_password: “{{ ansible\_password }}”
