Ansible copy file module to Windows host fails

Hi All,

I’m running Ansible 1.8.2 on a CentOS 6.6 server.

I’m trying to copy a file to a windows host, but the copy module fails. The weird thing is that I do see that it does PUT the file over to the remote windows host, but it fails when it tries to execute the powershell to rename the file to the destination directory.
If I abort the command before it removes the temporary files I can confirm the remote “source” file is the actual file. It looks like the failure is on the remote end to rename the file. Any ideas if this can be fixed? It’s a rather important feature for me to be able to distribute powershell scripts for remote execution.

Thanks!

[jklee@l99app09 poc]$ cat testcopy.yml

ansible-playbook -i hosts testcopy.yml --extra-vars=“source=‘list-installed-programs.ps1’ d=‘C:\Users\jklee\list-installed-programs.ps1’”

Ansible 1.8.x does not support the copy module for windows hosts. A win_copy module was just merged into devel (which will become 1.9):

https://github.com/ansible/ansible-modules-core/pull/384
https://github.com/ansible/ansible/pull/9611

Thanks. I found out that win_copy has a pull request about to be merged into 1.9

I also found a resource for copy.ps1 which works – I don’t need all the bells and whistles and a rudimentary copy function is all that’s needed for now.
Although, for the purposes of just running a powershell script, the script module works well too.

Thanks again!

Can you share your code that works an how did you did it?

References:
https://groups.google.com/forum/#!topic/ansible-devel/Jl5qP73CiKo

Place this copy.ps1 to /usr/lib/python2.6/site-packages/ansible/modules/core/windows/copy.ps1

https://gist.github.com/tkinz27/fd92ba9af0e0309614ee

Tho it’s probably not needed if you can use the win_url module or if you just want to run a powershell script, the script module works too.