You need to stop trying to map a network drive and then copying from that 
drive, as I said I don't believe it is possible and have never been able to 
get it working from a WinRM session. There are 2 ways you can do this 
currently, with Ansible 2.5 is out you can do this

become with become flags

- win_copy:
    src: \\192.168.20.13\WuhanTeam\100_test
    dest: C:\tools
  become: yes
  become_method: runas
  become_flags: logon_type=new_credentials logon_flags=netcredentials_only
  vars:
    ansible_become_user: xie11
    ansible_become_pass: 111111

Unfortunately the become_flags were not added until 2.5 so for older 
versions you need to do something like this

- win_shell: |
    $username = 'xie11'
    $password = '111111'
    $sec_password = ConvertTo-SecureString -String $password -AsPlainText -
Force
    $credentials = New-Object -TypeName PSCredential -ArgumentList $username
, $sec_password
    New-PSDrive -Name temp_path -PSProvider FileSystem -Root 
'\\192.168.20.13\WuhanTeam' -Credential $credential -Scope Script
    Copy-Item -Path temp_path:\100_test -DestinationPath C:\tools

That win_shell task, registers a temporary network path using a custom set 
of credentials and then copies the file from that temporary path with those 
credentials. This works because everything happens under that one script 
scope whereas running net use and then the xcopy commands as separate tasks 
do not (each task is run under a different shell)

Thanks

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/60a1804c-8525-4e84-8541-1d39f86930a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to