Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github_webhook module #35813

Merged
merged 3 commits into from Dec 6, 2018
Merged

Conversation

stpierre
Copy link
Contributor

@stpierre stpierre commented Feb 6, 2018

SUMMARY

github_webhook lets you easily create, update and delete Github webhooks.

This is part of a two-part replacement for github_hooks, which lacks a number of important features and has a strange interface.

The other parts are:

github_hooks lacks a number of important features: The ability to specify the events on which a webhook should fire; the ability to add a shared secret to a hook; the ability to create hooks that do not verify SSL against their target; and more. I considered merely updating that module to add the features needed, but the existing interface is pretty odd and would be difficult to update in a backwards-compatible way. For instance, it has a built-in feature for deleting all hooks whose last request returned 504 (action: clean504), but no way to update an existing hook, or delete a specific hook. It requires you to provide the API URL to a repository, rather than just the name of the repo (and optionally a Github API base), which requires a fair degree of familiarity with the Github API.

It has other issues that are easier to fix, but still weighed in on my decision to replace rather than upgrade: it rolls its own API client layer rather than using an existing library; it appears to support both password and API token auth, but only accepts a single oauthkey argument, which is a misnomer in both cases.

Rather than try to update it and fix all of the issues, I replaced it with two modules whose usage patterns are, I hope, much more intuitive.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

github_webhook

ANSIBLE VERSION
ansible 2.5.0 (github-webhook-module 4cdc321bfb) last updated 2018/02/06 16:13:32 (GMT -500)
  config file = None
  configured module search path = [u'/home/stpierre/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/stpierre/devel/ansible/lib/ansible
  executable location = /home/stpierre/devel/ansible/bin/ansible
  python version = 2.7.14 (default, Jan 17 2018, 14:28:32) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. labels Feb 6, 2018
@ansibot
Copy link
Contributor

ansibot commented Feb 6, 2018

@adrianmoisey @Akasurde @andreparames @bincyber @dj-wasabi @djmattyg007 @dsummersl @pcgentry @yeukhon

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Feb 8, 2018
@ansibot ansibot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. labels Feb 9, 2018
@ansibot
Copy link
Contributor

ansibot commented Feb 9, 2018

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/source_control/github_webhook.py:0:0: E307 version_added should be 2.6. Currently 2.5

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. community_review In order to be merged, this PR must follow the community review workflow. and removed community_review In order to be merged, this PR must follow the community review workflow. ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Feb 9, 2018
@djmattyg007
Copy link
Contributor

shipit

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 20, 2018
@ansibot
Copy link
Contributor

ansibot commented Mar 16, 2018

The test ansible-test sanity --test validate-modules [explain] failed with 2 errors:

lib/ansible/modules/source_control/github_webhook.py:0:0: E325 argument_spec for "active" defines type="bool" but documentation does not
lib/ansible/modules/source_control/github_webhook.py:0:0: E325 argument_spec for "insecure_ssl" defines type="bool" but documentation does not

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Mar 16, 2018
@@ -0,0 +1,240 @@
#!/usr/bin/python
#
# Copyright: (c) Ansible Project
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Copyright: (c) 2018, Ansible Project

DOCUMENTATION = '''
---
module: github_webhook
short_description: Manage Github webhooks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Github/GitHub/

short_description: Manage Github webhooks
version_added: "2.6"
description:
- "Create and delete Github webhooks"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add more description here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What more is needed? This seems sufficient to me.

break
except github.GithubException as err:
module.fail_json(
msg="Unable to get hooks from repository %s: %s" % to_native(err),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too few format values

Unable to get hooks from repository : %s" % to_native(err)

changed, data = create_hook(repo, module)
elif hook is not None and module.params["state"] == "absent":
hook.delete()
changed = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always return changed even if there is failure in deleting hook.

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Mar 19, 2018
@ansibot ansibot added the stale_review Updates were made after the last review and the last review is more than 7 days old. label Mar 27, 2018
@ansibot ansibot removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Apr 3, 2018
@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Apr 12, 2018
@ansibot ansibot added the affects_2.6 This issue/PR affects Ansible v2.6 label May 22, 2018
@ansibot
Copy link
Contributor

ansibot commented Nov 29, 2018

The test ansible-test sanity --test shebang [explain] failed with 1 error:

lib/ansible/modules/source_control/github_webhook.py:0:0: module should not be executable

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Nov 29, 2018
github_webhook lets you easily create, update and delete Github
webhooks.

This is part of a two-part replacement for github_hooks, which lacks a
number of important features and has a strange interface.
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Nov 29, 2018
@stpierre
Copy link
Contributor Author

@Akasurde I believe your objections have mostly been addressed.

@Akasurde
Copy link
Member

Need another pair of eyes to approve this.

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Nov 29, 2018
@acozine
Copy link
Contributor

acozine commented Dec 3, 2018

@stpierre thanks for the contributions. Are you willing to maintain this module and the github_webhook_facts module? If so, please add yourself to the maintenance list (above this line).

@gundalow
Copy link
Contributor

gundalow commented Dec 6, 2018

I made a change by specifying -name: for the examples d667575

@gundalow gundalow merged commit 891f1a5 into ansible:devel Dec 6, 2018
@gundalow
Copy link
Contributor

gundalow commented Dec 6, 2018

Merged into devel for release in Ansible 2.8

kbreit pushed a commit to kbreit/ansible that referenced this pull request Jan 11, 2019
* Add github_webhook module

github_webhook lets you easily create, update and delete Github
webhooks.

This is part of a two-part replacement for github_hooks, which lacks a
number of important features and has a strange interface.
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.6 This issue/PR affects Ansible v2.6 community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants