{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/10696","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/10696/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/10696/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/10696/events","html_url":"https://github.com/ansible/ansible/issues/10696","id":68254888,"number":10696,"title":"Knowing whether a playbook is run in check mode","user":{"login":"astorije","id":113730,"avatar_url":"https://avatars.githubusercontent.com/u/113730?v=3","gravatar_id":"","url":"https://api.github.com/users/astorije","html_url":"https://github.com/astorije","followers_url":"https://api.github.com/users/astorije/followers","following_url":"https://api.github.com/users/astorije/following{/other_user}","gists_url":"https://api.github.com/users/astorije/gists{/gist_id}","starred_url":"https://api.github.com/users/astorije/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astorije/subscriptions","organizations_url":"https://api.github.com/users/astorije/orgs","repos_url":"https://api.github.com/users/astorije/repos","events_url":"https://api.github.com/users/astorije/events{/privacy}","received_events_url":"https://api.github.com/users/astorije/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/feature_idea","name":"feature_idea","color":"006b75"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-14T03:49:52Z","updated_at":"2016-04-07T22:50:37Z","closed_at":"2016-04-07T22:50:37Z","body":"##### Issue Type:\r\n\r\nFeature Idea\r\n\r\n##### Ansible Version:\r\n\r\nTo this day, this feature does not exist. I am running `ansible 1.9.0.1`.\r\n\r\n##### Environment:\r\n\r\nN/A\r\n\r\n##### Summary:\r\n\r\nIt is natively impossible to know from a task, a role, or a playbook, if we are running in [check mode](http://docs.ansible.com/playbooks_checkmode.html) or not.\r\n\r\n##### Steps To Reproduce:\r\n\r\nIt can be very useful though. For example, some module (`ufw`, `git`, ...) require that the underlying executable must be installed. Lots of roles do that as a first task. If the task is run in check mode for the first time, the role will fail. Same applies if you try to do changes to a user that was not created, to create a symlink on a file that was not copied over yet, ...\r\n\r\nIn some cases, just knowing that we are in check mode is enough (although I agree that some cases require more work, like checking the presence of an executable which `which`, the presence of a user with `id`, ... but in the end, knowing that we are in check mode is still very valuable even in those cases).\r\n\r\n##### Expected Results:\r\n\r\nA variable? An extra fact? A extra directive at the same level than `always_run`, `when`, ... ? Not sure what is the best way to present this but I'd be happy to have others' opinions.\r\n\r\n##### Actual Results:\r\n\r\nSince it's not part of Ansible yet, it's still doable but through very [hacky solutions](http://stackoverflow.com/questions/28729567/skip-ansible-task-when-running-in-check-mode). This same page also shows some more use cases for this."}}