Unable to copy the files using the network path.

Hello,

Im unable to copy the files from the windows host to network path. Initially I tried to copy the files using NTLM authentication method and got the error as “Access denied”. After using the Kerberos authentication method im able to copy the files successfully to the network path.

After that the playbook is executing successfully but unable to copy the files. Not getting any error but files are not copying.

The following is the playbook, Can any one help please on this?

---

- name: Copying files to Networkpath
  hosts: '{{ remote_host }}'
  tasks:
  - name: Copying
    win_copy: 

      dest: "//Network//path//to//copy//"
       src: "G://mydata//sample//"
       remote_src: yes
       become_method: runas
       become_user: SYSTEM

Output: ok=2 changed=0 unreachable=0 failed=0

2 things;

  1. You are unable to copy from a network path due to the double hop issue

There are numerous docs out there detailing the double hop/credential delegation issue with WinRM, we have some details here as well https://docs.ansible.com/ansible/devel/user_guide/windows_winrm.html#limitations. To bypass this you can

  • Use Kerberos with credential delegation enabled
  • Use CredSSP
  • Use become on the Ansible task
  • Some more you can do but a bit more complicated for simple file copies
  1. You are trying to copy a file from a mapped drive (not sure but G is pretty far down the list for a local drive)

Mapped drives are not available in a WInRM logon for various reasons. Always use the UNC path when dealing with network files with WinRM.

  1. You are becoming the SYSTEM account

Unless you’ve messed around with the SYSTEM profile, it shouldn’t have any mapped drives. Also the SYSTEM account is designed for local actions and not remote authentication.

Thanks

Jordan

Hi Jordan,

Thanks for your reply. I used the Kerberos authentication method to avoid the double hope authentication issues. For the first time the playbook executed successfully and copied the files to remote path.

later when I tried to execute the same playbook, the files were not copied to the remote path and not getting any error in the output. while using the ‘become’ method getting the error.

Inventory file: