diff --git a/lib/ansible/modules/source_control/github_webhook.py b/lib/ansible/modules/source_control/github_webhook.py index b87e4377f1..efb76c4b5b 100644 --- a/lib/ansible/modules/source_control/github_webhook.py +++ b/lib/ansible/modules/source_control/github_webhook.py @@ -255,6 +255,8 @@ def main(): for hook in repo.get_hooks(): if hook.config.get("url") == module.params["url"]: break + else: + hook = None except github.GithubException as err: module.fail_json(msg="Unable to get hooks from repository %s: %s" % ( module.params["repository"], to_native(err)))