# File permission problems with copy module over cygwin ssh.

**URL:** <https://forum.ansible.com/t/file-permission-problems-with-copy-module-over-cygwin-ssh/16406>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [October 2, 2014, 3:42pm UTC](https://forum.ansible.com/t/file-permission-problems-with-copy-module-over-cygwin-ssh/16406 "2014-10-02T15:42:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heath\_Henjum](https://avatars.discourse-cdn.com/v4/letter/h/9d8465/32.png) [@Heath\_Henjum](https://forum.ansible.com/u/Heath_Henjum)\
**Post date:** [October 2, 2014, 3:42pm UTC](https://forum.ansible.com/t/file-permission-problems-with-copy-module-over-cygwin-ssh/16406/1 "2014-10-02T15:42:05Z")

</div>

Control server is linux…

I’m trying to copy a file to a windows server using the template module (the file exists on windows too so I’m trying to overwrite), but I always get a permission denied error if I don’t explicitly own the file on the windows server.

1. I have full control rights on the file.
2. I can scp the file from the command line on our ansible control server using the same credentials without a problem. (I’ve tried both ssh keys and ansible\_ssh\_pass).
3. I can also do an ssh and remove the file… in addition, can ssh and chown even.
4. Also, the copy module works ok.

Is this a python restriction maybe?

Here is my task:

- name: “Copy template of defgen prm file to destination for env {{ playenv|default(‘all’) }}”  
template: src=defgen.prm.j2 dest={{ ogg\_home }}/{{ item.value.pfileloc }}/{{ item.value.pfile }}.prm backup=yes

when: \>  
item.value.dbsystem == playsystem  
and item.value.dbenv == “{{ playenv|default(item.value.dbenv) }}”  
and item.value.app | search(“{{ playapp|default(item.value.app) }}”)  
and item.value.dc == “{{ playdc|default(item.value.dc) }}”  
and item.key | search(“{{ defnm|default(item.key) }}”)  
with\_dict: defgensrc | default({})

Here is the error:

failed: [mnssstg01.surescripts.int] =\> (item={‘value’: {‘destsrvr’: ‘mn-lctdbs02.surescripts.int’, ‘pfile’: ‘defgen\_sms2aud’, ‘app’: ‘sms’, ‘dc’: ‘MN’, ‘destdir’: ‘dirdef/oraclesm’, ‘tablistsrc’: ‘oraclesm/eosms\*.prm’, ‘defsfile’: ‘mssql\_sms\_table.def’, ‘pfileloc’: ‘dirprm/oraclesm’, ‘dbsystem’: ‘staging’, ‘dbenv’: ‘SMS’, ‘connstr’: ‘sourcedb SMS-STAGING-MSP’, ‘outputloc’: u’L:\OGG\dirprm\oraclesm’}, ‘key’: ‘staging\_sms2aud’}) =\> {“failed”: true, “item”: {“key”: “staging\_sms2aud”, “value”: {“app”: “sms”, “connstr”: “sourcedb SMS-STAGING-MSP”, “dbenv”: “SMS”, “dbsystem”: “staging”, “dc”: “MN”, “defsfile”: “mssql\_sms\_table.def”, “destdir”: “dirdef/oraclesm”, “destsrvr”: “mn-lctdbs02.surescripts.int”, “outputloc”: “L:\OGG\dirprm\oraclesm”, “pfile”: “defgen\_sms2aud”, “pfileloc”: “dirprm/oraclesm”, “tablistsrc”: “oraclesm/eosms\*.prm”}}, “parsed”: false}  
invalid output was: Traceback (most recent call last):  
File “/home/svc\_dbdeploy/.ansible/tmp/ansible-tmp-1412258170.09-237634358968064/copy”, line 1438, in   
main()  
File “/home/svc\_dbdeploy/.ansible/tmp/ansible-tmp-1412258170.09-237634358968064/copy”, line 212, in main  
module.atomic\_move(src, dest)  
File “/home/svc\_dbdeploy/.ansible/tmp/ansible-tmp-1412258170.09-237634358968064/copy”, line 1243, in atomic\_move  
os.chown(src, dest\_stat.st\_uid, dest\_stat.st\_gid)  
OSError: [Errno 13] Permission denied: ‘/home/svc\_dbdeploy/.ansible/tmp/ansible-tmp-1412258170.09-237634358968064/source’

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 2, 2014, 8:55pm UTC](https://forum.ansible.com/t/file-permission-problems-with-copy-module-over-cygwin-ssh/16406/2 "2014-10-02T20:55:42Z")

</div>

Hi, I’m not sure about your cygwin question, but Ansible doesn’t support cygwin.

We use the “winrm” connection to manage Windows guests.

I’m not sure if that’s related to your problem, however.

---

<div class="post-metadata">

**Author:** ![Heath\_Henjum](https://avatars.discourse-cdn.com/v4/letter/h/9d8465/32.png) [@Heath\_Henjum](https://forum.ansible.com/u/Heath_Henjum)\
**Post date:** [October 2, 2014, 10:12pm UTC](https://forum.ansible.com/t/file-permission-problems-with-copy-module-over-cygwin-ssh/16406/3 "2014-10-02T22:12:58Z")

</div>

Yeah. I think we are going to move to winrm soon. I knew that cygwin wasn’t supported, but so far haven’t had too much trouble since we aren’t doing too much stuff on the windows side. Just a few shell commands, copy, template, etc.  
I have a feeling it’s something in the python distribution for cygwin, and not really ansible related.

I’ll try to work it up using winrm, and see if that works ok.

I just had a thought too… I can do the template task as a local action, and then push to the windows server with copy.

I wanted to make sure I wasn’t missing something obvious (other than the fact that windows file permissions are complicated!)

Thanks,  
Heath
