community.general.github_webhook 模块 – 管理 GitHub Webhook
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.general。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。
要在 playbook 中使用它,请指定:community.general.github_webhook。
概要
- 创建和删除 GitHub Webhook 
要求
执行此模块的主机需要以下要求。
- PyGithub >= 1.3.5 
参数
| 参数 | 注释 | 
|---|---|
| Webhook 是否处于活动状态 选项 
 | |
| 用于序列化有效负载的媒体类型 选项 
 | |
| 触发挂钩的 GitHub 事件列表。事件列在 https://developer.github.com/v3/activity/events/types/。除非  | |
| GitHub API 的基本 URL 默认值:  | |
| 指示 GitHub 在调用挂钩时是否应跳过 SSL 验证的标志。 选项 
 | |
| 用于对 GitHub 进行身份验证的密码 | |
| 要为其配置挂钩的存储库的全名 | |
| GitHub 和有效负载 URL 之间的共享密钥。 | |
| 挂钩是否存在 选项 
 | |
| 用于对 GitHub 进行身份验证的令牌 | |
| 将向其传递有效负载的 URL | |
| 用于对 GitHub 进行身份验证的用户 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:不支持 | 可以在  | |
| 支持:不支持 | 在差异模式下,将返回有关已更改内容(或可能需要在  | 
示例
- name: Create a new webhook that triggers on push (password auth)
  community.general.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)
  community.general.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)
  community.general.github_webhook:
    repository: ansible/ansible
    url: https://www.example.com/hooks/
    state: absent
    user: "{{ github_user }}"
    password: "{{ github_password }}"
返回值
常见的返回值已在此处记录 此处,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 创建/更新的挂钩的 GitHub ID 返回:当 state 为 ‘present’ 时 示例:  | 
