File permission problems with copy module over cygwin ssh.

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’

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.

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