diff --git a/changelogs/fragments/5994-github-webhook-secret.yml b/changelogs/fragments/5994-github-webhook-secret.yml new file mode 100644 index 0000000000..700703840c --- /dev/null +++ b/changelogs/fragments/5994-github-webhook-secret.yml @@ -0,0 +1,2 @@ +bugfixes: + - github_webhook - fix always changed state when no secret is provided (https://github.com/ansible-collections/community.general/pull/5994). \ No newline at end of file diff --git a/plugins/modules/source_control/github/github_webhook.py b/plugins/modules/source_control/github/github_webhook.py index b97087d221..f1f11ce10c 100644 --- a/plugins/modules/source_control/github/github_webhook.py +++ b/plugins/modules/source_control/github/github_webhook.py @@ -154,13 +154,18 @@ from ansible.module_utils.common.text.converters import to_native def _create_hook_config(module): - return { + hook_config = { "url": module.params["url"], "content_type": module.params["content_type"], - "secret": module.params.get("secret"), "insecure_ssl": "1" if module.params["insecure_ssl"] else "0" } + secret = module.params.get("secret") + if secret: + hook_config["secret"] = secret + + return hook_config + def create_hook(repo, module): config = _create_hook_config(module)