From 0943e2a0dfff02413fe7c2678c3299f98bfee908 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 27 Mar 2019 09:05:34 -0500 Subject: [PATCH] github_webhook: Fix create of new hook with existing hooks (#54458) When creating a new webhook with existing hooks already in place, the module would erroneously select one of the existing hooks to update instead of creating the hook anew. This fixes that bug. --- lib/ansible/modules/source_control/github_webhook.py | 2 ++ 1 file changed, 2 insertions(+) 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)))