github_webhook – Manage GitHub webhooks — Ansible Documentation

- AnsibleFest
- Products
- Community
- Webinars & Training
- Blog

Documentation

# github_webhook – Manage GitHub webhooks

New in version 2.8.

- Synopsis
- Requirements
- Parameters
- Examples
- Return Values
- Status

## Synopsis

- Create and delete GitHub webhooks

## Requirements

The below requirements are needed on the host that executes this module.

- PyGithub >= 1.3.5

## Parameters

Parameter | Choices/Defaults | Comments
--- | --- | ---
active boolean | Choices: no yes ← | Whether or not the hook is active
content_type - | Choices: form ← json | The media type used to serialize the payloads
events - |  | A list of GitHub events the hook is triggered for. Events are listed at https://developer.github.com/v3/activity/events/types/. Required unless `state` is `absent`
github_url - | Default: "https://api.github.com" | Base URL of the GitHub API
insecure_ssl boolean | Choices: no ← yes | Flag to indicate that GitHub should skip SSL verification when calling the hook.
password - |  | Password to authenticate to GitHub with
repository - / required |  | Full name of the repository to configure a hook for aliases: repo
secret - |  | The shared secret between GitHub and the payload URL.
state - | Choices: absent present ← | Whether the hook should be present or absent
token - |  | Token to authenticate to GitHub with
url - / required |  | URL to which payloads will be delivered
user - / required |  | User to authenticate to GitHub as

## Examples

    - name:  create a new webhook that triggers on push (password auth)
      github_webhook:
        repository: ansible/ansible
        url: https://www.example.com/hooks/
        events:
          - push
        user: "{{ github_user }}"
        password: "{{ github_password }}"

    - name: create a new webhook in a github enterprise installation with multiple event triggers (token auth)
      github_webhook:
        repository: myorg/myrepo
        url: https://jenkins.example.com/ghprbhook/
        content_type: json
        secret: "{{ github_shared_secret }}"
        insecure_ssl: True
        events:
          - issue_comment
          - pull_request
        user: "{{ github_user }}"
        token: "{{ github_user_api_token }}"
        github_url: https://github.example.com

    - name: delete a webhook (password auth)
      github_webhook:
        repository: ansible/ansible
        url: https://www.example.com/hooks/
        state: absent
        user: "{{ github_user }}"
        password: "{{ github_password }}"

## Return Values

Common return values are documented here, the following are the fields unique to this module:

Key | Returned | Description
--- | --- | ---
hook_id integer | when state is 'present' | The GitHub ID of the hook created/updated Sample: 6206

## Status

- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]

### Authors

- Chris St. Pierre (@stpierre)

Hint

If you notice any issues in this documentation you can edit this document to improve it.