{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/42107","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/42107/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/42107/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/42107/events","html_url":"https://github.com/ansible/ansible/issues/42107","id":337008846,"node_id":"MDU6SXNzdWUzMzcwMDg4NDY=","number":42107,"title":"Fail flag for `no hosts matched`","user":{"login":"sumkincpp","id":738925,"node_id":"MDQ6VXNlcjczODkyNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/738925?v=4","gravatar_id":"","url":"https://api.github.com/users/sumkincpp","html_url":"https://github.com/sumkincpp","followers_url":"https://api.github.com/users/sumkincpp/followers","following_url":"https://api.github.com/users/sumkincpp/following{/other_user}","gists_url":"https://api.github.com/users/sumkincpp/gists{/gist_id}","starred_url":"https://api.github.com/users/sumkincpp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumkincpp/subscriptions","organizations_url":"https://api.github.com/users/sumkincpp/orgs","repos_url":"https://api.github.com/users/sumkincpp/repos","events_url":"https://api.github.com/users/sumkincpp/events{/privacy}","received_events_url":"https://api.github.com/users/sumkincpp/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-29T13:56:22Z","updated_at":"2018-06-29T14:01:10Z","closed_at":"2018-06-29T14:01:10Z","author_association":"CONTRIBUTOR","body":"##### SUMMARY\r\n\r\nThis feature was floating around for a while, strangely it isn't currently supported in ansible.\r\n\r\nWould be great to have a new flag for playbooks which will show if we should fail on `no hosts matched` condition\r\n\r\nMight be implemented with custom action module like the following\r\n```yaml\r\n- name: Check supplied hosts\r\n  connection: local\r\n  gather_facts: no\r\n  hosts: all\r\n  hosts_fail: on_empty\r\n  tasks:\r\n   ...\r\n```\r\nor with a flag.\r\n\r\nVery useful within workflows without tricks, like [this](https://stackoverflow.com/questions/48901168/how-to-avoid-a-playbook-to-run-when-no-host-matches).\r\n\r\nRelevant to #14693\r\n\r\n##### ISSUE TYPE\r\n - Feature Idea\r\n\r\n##### COMPONENT NAME\r\nAnsible playbooks\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/401363292","html_url":"https://github.com/ansible/ansible/issues/42107#issuecomment-401363292","issue_url":"https://api.github.com/repos/ansible/ansible/issues/42107","id":401363292,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTM2MzI5Mg==","user":{"login":"sumkincpp","id":738925,"node_id":"MDQ6VXNlcjczODkyNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/738925?v=4","gravatar_id":"","url":"https://api.github.com/users/sumkincpp","html_url":"https://github.com/sumkincpp","followers_url":"https://api.github.com/users/sumkincpp/followers","following_url":"https://api.github.com/users/sumkincpp/following{/other_user}","gists_url":"https://api.github.com/users/sumkincpp/gists{/gist_id}","starred_url":"https://api.github.com/users/sumkincpp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumkincpp/subscriptions","organizations_url":"https://api.github.com/users/sumkincpp/orgs","repos_url":"https://api.github.com/users/sumkincpp/repos","events_url":"https://api.github.com/users/sumkincpp/events{/privacy}","received_events_url":"https://api.github.com/users/sumkincpp/received_events","type":"User","site_admin":false},"created_at":"2018-06-29T14:01:10Z","updated_at":"2018-06-29T14:01:10Z","author_association":"CONTRIBUTOR","body":"Already discussed as feature that won't measured in #14742.\r\nWorkaround is a callback [here](https://gist.github.com/jjshoe/ace3070906e5bc5cc432)"}}
{"actor":{"display_login":"sumkincpp"}}