# chmod not working

**URL:** <https://forum.ansible.com/t/chmod-not-working/26412>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [January 3, 2018, 10:51pm UTC](https://forum.ansible.com/t/chmod-not-working/26412 "2018-01-03T22:51:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpescatore](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lpescatore](https://forum.ansible.com/u/lpescatore)\
**Post date:** [January 3, 2018, 10:51pm UTC](https://forum.ansible.com/t/chmod-not-working/26412/1 "2018-01-03T22:51:00Z")

</div>

HI, I have a play that SHOULD copy a file over from my server to a Windows box AND set permissions to 660 (notice I have tried both modes below separately):

win\_copy:

src: /ansible/playbook/foo.foo

dest: C:\mydir\foo.foo

state: file

mode: “ug+rw”

OR mode: 0660

The play runs w/o fail.

Unfortunately, though, when I stat the file I see:

$ stat foo.foo

File: foo.foo

Size: 17 Blocks: 1 IO Block: 65536 regular file

Device: d22da4adh/3526206637d Inode: 562949953957599 Links: 1

Access: (0755/-rwxr-xr-x) Uid: ( 544/Administrators) Gid: (197121/ None)

Access: 2018-01-03 14:17:25.989300300 -0800

Modify: 2018-01-03 14:17:20.822769500 -0800

Change: 2018-01-03 14:17:20.822769500 -0800

Birth: 2018-01-03 14:17:25.989300300 -0800

Any idea WHY?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 3, 2018, 11:05pm UTC](https://forum.ansible.com/t/chmod-not-working/26412/2 "2018-01-03T23:05:31Z")

</div>

From what I can tell of the documentation, `win_copy` does not support a `mode` argument. It’s likely just being ignored, due to how the argument parsing in windows modules is currently handled.

[http://docs.ansible.com/ansible/latest/win\_copy\_module.html](http://docs.ansible.com/ansible/latest/win_copy_module.html)

---

<div class="post-metadata">

**Author:** ![lpescatore](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lpescatore](https://forum.ansible.com/u/lpescatore)\
**Post date:** [January 3, 2018, 11:11pm UTC](https://forum.ansible.com/t/chmod-not-working/26412/3 "2018-01-03T23:11:31Z")

</div>

Wow, that’s something HOPEFULLY will be supported in the future. Thank you.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [January 4, 2018, 3:05am UTC](https://forum.ansible.com/t/chmod-not-working/26412/4 "2018-01-04T03:05:41Z")

</div>

Windows does not use the standard user/group/all permissions that are in use with most unix servers so the mode option most likely will never be supported. Windows uses ACLs [https://msdn.microsoft.com/en-us/library/windows/desktop/aa374872(v=vs.85).aspx?f=255&MSPPError=-2147217396](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374872%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396) to set permissions on files and folders and these are a lot more complicated than the mode permissions.

While you can’t do it in one task with win\_copy, the win\_acl [http://docs.ansible.com/ansible/latest/win\_acl\_module.html](http://docs.ansible.com/ansible/latest/win_acl_module.html) module is designed to set ACL’s on a file/folder to achieve a similar result.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![lpescatore](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lpescatore](https://forum.ansible.com/u/lpescatore)\
**Post date:** [January 5, 2018, 4:23pm UTC](https://forum.ansible.com/t/chmod-not-working/26412/5 "2018-01-05T16:23:34Z")

</div>

Thanks Jordan,  
I am trying win\_acl:

- name: chmod foo.foo

win\_acl:

user: user

path: C:\cygwin\etc\foo.foo

type: allow

state: present

rights: Read,Write

BUT–

When I stat I still get:

Access: (0755/-rwxr-xr-x) Uid: ( 544/Administrators) Gid: (197121/ None)

Please note I’ve tried using user: Administrators instead of the specific user.

Any idea why it doesn’t work?
