{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/7490","labels_url":"https://api.github.com/repos/ansible/ansible/issues/7490/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/7490/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/7490/events","html_url":"https://github.com/ansible/ansible/issues/7490","id":34074911,"number":7490,"title":"Add state=present to file module (rather than state=touch)","user":{"login":"hjwp","id":769730,"avatar_url":"https://avatars.githubusercontent.com/u/769730?v=3","gravatar_id":"","url":"https://api.github.com/users/hjwp","html_url":"https://github.com/hjwp","followers_url":"https://api.github.com/users/hjwp/followers","following_url":"https://api.github.com/users/hjwp/following{/other_user}","gists_url":"https://api.github.com/users/hjwp/gists{/gist_id}","starred_url":"https://api.github.com/users/hjwp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hjwp/subscriptions","organizations_url":"https://api.github.com/users/hjwp/orgs","repos_url":"https://api.github.com/users/hjwp/repos","events_url":"https://api.github.com/users/hjwp/events{/privacy}","received_events_url":"https://api.github.com/users/hjwp/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2014-05-22T12:03:36Z","updated_at":"2015-06-02T14:20:08Z","closed_at":"2014-05-22T13:27:22Z","body":"\r\n\r\n##### Issue Type: Feature Idea\r\n##### Ansible Version: ansible 1.5.5\r\n##### Environment: Linux\r\n##### Summary:\r\n\r\ncf discussion on #4097.  Although `state=touch` works pretty well, something called `state=present` would be more useful for (what I think is) a very common use case.\r\n\r\n##### Steps To Reproduce: n/a\r\n##### Expected Results: n/a\r\n##### Actual Results: n/a\r\n\r\n\r\nThe example is: making sure that a log file is present, and has the correct perms to be written to by a program.\r\n\r\nWhat's desired is that ansible should create the file, and give it the correct permissions, if it doesn't exist.  This is already achieved by the `state=touch` option. \r\n\r\nHowever, `touch` has a couple of undesirable side-effects in this use case.  Firstly, it does a `touch` even when the file does already exist and has the correct perms, which causes spurious updates to the log files last modified & accessed perms.  Secondly, ansible registers the step as \"changed\" every time it's run, even though, as far as I cared, there was nothing that needed to be done.  This makes it hard to, eg, drive a correct handler notification from the step.\r\n\r\nSo, a minor enhancement proposal, but a useful one I think."},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/107970898","html_url":"https://github.com/ansible/ansible/issues/7490#issuecomment-107970898","issue_url":"https://api.github.com/repos/ansible/ansible/issues/7490","id":107970898,"user":{"login":"assarbad","id":3238620,"avatar_url":"https://avatars.githubusercontent.com/u/3238620?v=3","gravatar_id":"","url":"https://api.github.com/users/assarbad","html_url":"https://github.com/assarbad","followers_url":"https://api.github.com/users/assarbad/followers","following_url":"https://api.github.com/users/assarbad/following{/other_user}","gists_url":"https://api.github.com/users/assarbad/gists{/gist_id}","starred_url":"https://api.github.com/users/assarbad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/assarbad/subscriptions","organizations_url":"https://api.github.com/users/assarbad/orgs","repos_url":"https://api.github.com/users/assarbad/repos","events_url":"https://api.github.com/users/assarbad/events{/privacy}","received_events_url":"https://api.github.com/users/assarbad/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T14:20:08Z","updated_at":"2015-06-02T14:20:08Z","body":"Same here: +1 for the `state=present` proposal."}}