copy file from remote windows server to local machine?

In Ansible 2.0, the win_copy module will move a local file to a remote windows machine.

Is there an Ansible way to fetch a remote file on a windows server and move it to a local machine?

J

Line 85 in the win_copy module is the chunk that actually copies the file from the local to remote. Perhaps try executing a raw command to test it out? Something along the lines of:

  • name: copy to local from remote
    raw: Copy-Item -Path {{remoteFileLocation}} -Destination {{localFileLocation}} -Force

Can’t test this currently, but can do in the morning.

I think this will work but I’d have to know how to specify the destination location (my Mac laptop) in a way
that makes sense to Powershell Remoting. I have no clue how to do that.

The very last answer to this stackoverflow demonstrates the methodology. Any Windows/PS pros in the house?

http://stackoverflow.com/questions/9304953/copy-files-from-remote-rdp-to-local-machine

J

More relevant discussion: http://stackoverflow.com/questions/10741609/copy-file-remotely-with-powershell

Anyone know what the destination format would be in Powershell to target the local desktop?

J

I may be missing the point here but is the fetch module what you need? Fetch works against windows hosts and linux hosts.

Plenty of examples in the integration tests here: https://github.com/ansible/ansible/blob/devel/test/integration/roles/test_win_fetch/tasks/main.yml

Hope this helps,

Jon

I forgot that it was mentioned in the docs. Maybe there should be an
"alias" page in the list of "Windows" modules.

Thanks!

J