{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/13159","labels_url":"https://api.github.com/repos/ansible/ansible/issues/13159/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/13159/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/13159/events","html_url":"https://github.com/ansible/ansible/issues/13159","id":116795336,"number":13159,"title":"File mode gives unpredictable results","user":{"login":"hs-calc","id":10299338,"avatar_url":"https://avatars.githubusercontent.com/u/10299338?v=3","gravatar_id":"","url":"https://api.github.com/users/hs-calc","html_url":"https://github.com/hs-calc","followers_url":"https://api.github.com/users/hs-calc/followers","following_url":"https://api.github.com/users/hs-calc/following{/other_user}","gists_url":"https://api.github.com/users/hs-calc/gists{/gist_id}","starred_url":"https://api.github.com/users/hs-calc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hs-calc/subscriptions","organizations_url":"https://api.github.com/users/hs-calc/orgs","repos_url":"https://api.github.com/users/hs-calc/repos","events_url":"https://api.github.com/users/hs-calc/events{/privacy}","received_events_url":"https://api.github.com/users/hs-calc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-13T15:52:55Z","updated_at":"2015-11-13T16:38:26Z","closed_at":null,"body":"When using the yaml syntax for modules \"mode\" gives weird results unless they are quoted, this opens up for unpredictable errors so it should either give a warning or work the same way no matter if it's quoted or not.\r\n```\r\n- file:\r\n    path: /tmp/t1\r\n    state: directory\r\n    mode: 2775\r\ngives unexpected result:\r\nd-ws-w-rwt   2 root root 4.0K Nov 13 14:59 t1\r\n```\r\n```\r\n- file: > \r\n    path=/tmp/t2\r\n    state=directory\r\n    mode=2775\r\ngives result:\r\ndrwxrwsr-x   2 root root 4.0K Nov 13 14:59 t2\r\n```\r\n```\r\n- file:\r\n    path: /tmp/t3\r\n    state: directory\r\n    mode: \"2775\"\r\ngives result:\r\ndrwxrwsr-x   2 root root 4.0K Nov 13 14:59 t3\r\n```\r\nTested on ansible 1.9.4 and 2.0.0 (devel b2a9111b22)\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/156482308","html_url":"https://github.com/ansible/ansible/issues/13159#issuecomment-156482308","issue_url":"https://api.github.com/repos/ansible/ansible/issues/13159","id":156482308,"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-13T16:38:26Z","updated_at":"2015-11-13T16:38:26Z","body":"This is do to how python and pyyaml handle octal and decimal modes.\r\n\r\nThe equivalents are:\r\n\r\n#### Proper Octal\r\n```\r\nmode: 02775\r\n```\r\n\r\n#### Octal represented as a string\r\n```\r\nmode: \"2775\"\r\n```\r\n\r\n#### Mode as a decimal\r\n\r\n```\r\nmode: 1517\r\n```\r\n\r\nThe reason that `mode=2775` produces the same results as `mode: \"2775\"` is due to the fact sure that `key=value` ansible uses shlex to parse the values, effectively casting all values to strings."}}