{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/13115","labels_url":"https://api.github.com/repos/ansible/ansible/issues/13115/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/13115/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/13115/events","html_url":"https://github.com/ansible/ansible/issues/13115","id":116138220,"number":13115,"title":"\"mode\" in various module is not working if you put directly the octal value","user":{"login":"sterfield","id":5747061,"avatar_url":"https://avatars.githubusercontent.com/u/5747061?v=3","gravatar_id":"","url":"https://api.github.com/users/sterfield","html_url":"https://github.com/sterfield","followers_url":"https://api.github.com/users/sterfield/followers","following_url":"https://api.github.com/users/sterfield/following{/other_user}","gists_url":"https://api.github.com/users/sterfield/gists{/gist_id}","starred_url":"https://api.github.com/users/sterfield/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sterfield/subscriptions","organizations_url":"https://api.github.com/users/sterfield/orgs","repos_url":"https://api.github.com/users/sterfield/repos","events_url":"https://api.github.com/users/sterfield/events{/privacy}","received_events_url":"https://api.github.com/users/sterfield/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-10T16:06:26Z","updated_at":"2015-11-10T17:00:36Z","closed_at":null,"body":"# context\r\n\r\n* Ansible version: 1.9.4\r\n* OS targeted: confirmed on Mac OS and Debian *\r\n\r\n# steps to reproduce\r\n\r\n1. create a file, for example /tmp/test\r\n2. create a file with this code:\r\n```yaml\r\n---\r\n- hosts: all\r\n  tasks:\r\n      file:\r\n        path: /tmp/test\r\n        mode: 4755\r\n```\r\n3. execute the playbook\r\n```bash\r\nansible -i <target> -u root -k test_mode.yml\r\n```\r\n\r\n# Current results\r\nThe file will have some strange rights:\r\n```\r\n--w--w--wt  1 root  root  0 Nov 10 16:48 /tmp/test\r\n```\r\n\r\n# Expected results\r\nThe file should have the correct rights:\r\n```bash\r\nchmod 4755 /tmp/test\r\nls -l /tmp/test\r\n-rwsr-xr-x  1 root  root  0 Nov 10 16:48 /tmp/test\r\n```\r\n\r\n# Additional note\r\n\r\n* The quick workaround is to put the octal parameters between quotes and the issue disappear.\r\n* The issue is not present if you put the mode in octal, without specifying set uid or set gid. For example, this works:\r\n```\r\n...\r\nmode: 0755\r\n...\r\n```\r\nThe result: \r\n```\r\n-rwxr-xr-x  1 root  root  0 Nov 10 16:48 /tmp/test\r\n```\r\n* This issue is present in multiple modules, confirmed with \"file\" and \"copy\" module.\r\n* If you use a file \"mode\" in symbolic notation, it works fine.\r\n\r\nThanks! "},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/155486698","html_url":"https://github.com/ansible/ansible/issues/13115#issuecomment-155486698","issue_url":"https://api.github.com/repos/ansible/ansible/issues/13115","id":155486698,"user":{"login":"sivel","id":39340,"avatar_url":"https://avatars.githubusercontent.com/u/39340?v=3","gravatar_id":"","url":"https://api.github.com/users/sivel","html_url":"https://github.com/sivel","followers_url":"https://api.github.com/users/sivel/followers","following_url":"https://api.github.com/users/sivel/following{/other_user}","gists_url":"https://api.github.com/users/sivel/gists{/gist_id}","starred_url":"https://api.github.com/users/sivel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sivel/subscriptions","organizations_url":"https://api.github.com/users/sivel/orgs","repos_url":"https://api.github.com/users/sivel/repos","events_url":"https://api.github.com/users/sivel/events{/privacy}","received_events_url":"https://api.github.com/users/sivel/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T17:00:36Z","updated_at":"2015-11-10T17:00:36Z","body":"If the mode does not start with a `0`, you need to quote the mode, otherwise it is assumed to be a decimal mode instead of an octal mode.  Decimal mode `4755` is equivalent to octal mode `011223`, which causes your strange permissions.\r\n\r\nSolutions:\r\n\r\n```\r\nmode: 04755\r\n```\r\n\r\nor \r\n\r\n```\r\nmode: \"4755\"\r\n```"}}