copy file from remote windows server to local machine?

2,057 views
Skip to first unread message

Slim Slam

unread,
Feb 17, 2016, 11:16:34 PM2/17/16
to Ansible Project
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

Gerald Spencer

unread,
Feb 18, 2016, 12:35:14 AM2/18/16
to Ansible Project
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. 

Slim Slam

unread,
Feb 19, 2016, 2:51:00 PM2/19/16
to Ansible Project
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?


J

Slim Slam

unread,
Feb 20, 2016, 1:18:09 AM2/20/16
to Ansible Project

Slim Slam

unread,
Feb 21, 2016, 9:49:55 PM2/21/16
to Ansible Project
Anyone know what the destination format would be in Powershell to target the local desktop?

J

J Hawkesworth

unread,
Feb 22, 2016, 3:57:31 AM2/22/16
to Ansible Project
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

Jason Levitt

unread,
Feb 22, 2016, 10:09:35 AM2/22/16
to ansible...@googlegroups.com
I forgot that it was mentioned in the docs. Maybe there should be an
"alias" page in the list of "Windows" modules.

Thanks!

J
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/1VZon0MStMM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/569b2b11-6986-4bf5-b9a2-b14563074ab4%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages