awx.awx.notification_template 模块 – 创建、更新或销毁自动化平台控制器通知。
注意
此模块是 awx.awx 集合(版本 24.6.1)的一部分。
如果您使用的是 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install awx.awx。
要在 playbook 中使用它,请指定:awx.awx.notification_template。
概要
- 创建、更新或销毁自动化平台控制器通知。有关概述,请参阅 https://ansible.org.cn/tower。 
别名:tower_notification,tower_notification_template
参数
| 参数 | 注释 | 
|---|---|
| 控制器配置文件的路径。 如果提供,则不会考虑其他配置文件位置。 | |
| 您的自动化平台控制器实例的 URL。 如果未设置值,将尝试环境变量  如果未通过任何方式指定值,将使用  | |
| 要使用的 OAuth 令牌。 此值可以是以下两种格式之一。 一个字符串,它是令牌本身。(即 bqV5txm97wqJqtkxlMkhQz0pKhRMMX) 令牌模块返回的字典结构。 如果未设置值,将尝试环境变量  | |
| 您的控制器实例的密码。 如果未设置值,将尝试环境变量  | |
| 您的控制器实例的用户名。 如果未设置值,将尝试环境变量  | |
| 用于复制通知的名称或 ID。 这将复制现有的通知并更改任何提供的参数。 新通知的名称将是在 name 参数中提供的名称。 此选项不使用 organization 参数,以方便从一个组织复制到另一个组织。 如果多个通知共享相同的名称,请提供 ID 或使用查找插件提供 ID。 | |
| 通知的描述。 | |
| 通知模板的可选自定义消息。 | |
| 通知的名称。 | |
| 设置此选项将更改现有名称(通过 name 字段查找)。 | |
| 通知配置文件。请注意,提供此字段将禁用所有与通知配置相关的字段。 username(邮件服务器用户名) sender(发件人电子邮件地址) recipients(收件人电子邮件地址) use_tls(TLS 触发器) host(邮件服务器主机) use_ssl(SSL 触发器) password(邮件服务器密码) port(邮件服务器端口) channels(目标 Slack 频道) token(访问令牌) account_token(Twillio 帐户令牌) from_number(源电话号码) to_numbers(目标电话号码) account_sid(Twillio 帐户 SID) subdomain(PagerDuty 子域) service_key(PagerDuty 服务/集成 API 密钥) client_name(PagerDuty 客户端标识符) message_from(通知中显示的标签) color(通知颜色) notify(通知频道触发器) url(目标 URL) headers(作为 JSON 字符串的 HTTP 标头) server(IRC 服务器地址) nickname(IRC 昵称) targets(目标频道或用户) | |
| 要发送的通知类型。 选项 
 | |
| 通知所属的组织名称、ID 或命名 URL。 | |
| 指定 Ansible 在请求控制器主机时应使用的超时。 默认为 10 秒,但这由共享 module_utils 代码处理 | |
| 资源的期望状态。 选项 
 | |
| 是否允许与 AWX 的不安全连接。 如果为  这应该仅在个人控制的使用自签名证书的站点上使用。 如果未设置值,将尝试环境变量  选项 
 | 
注释
注意
- 如果未提供 config_file,我们将尝试使用 tower-cli 库的默认值来查找您的主机信息。 
- config_file 的格式应如下:host=hostname username=username password=password 
示例
- name: Add Slack notification with custom messages
  notification_template:
    name: slack notification
    organization: Default
    notification_type: slack
    notification_configuration:
      channels:
        - general
      token: cefda9e2be1f21d11cdd9452f5b7f97fda977f42
    messages:
       started:
         message: "{{ '{{ job_friendly_name }}{{ job.id }} started' }}"
       success:
         message: "{{ '{{ job_friendly_name }} completed in {{ job.elapsed }} seconds' }}"
       error:
         message: "{{ '{{ job_friendly_name }} FAILED! Please look at {{ job.url }}' }}"
    state: present
    controller_config_file: "~/tower_cli.cfg"
- name: Add webhook notification
  notification_template:
    name: webhook notification
    notification_type: webhook
    notification_configuration:
      url: http://www.example.com/hook
      headers:
        X-Custom-Header: value123
    state: present
    controller_config_file: "~/tower_cli.cfg"
- name: Add email notification
  notification_template:
    name: email notification
    notification_type: email
    notification_configuration:
      username: user
      password: s3cr3t
      sender: [email protected]
      recipients:
        - [email protected]
      host: smtp.example.com
      port: 25
      use_tls: no
      use_ssl: no
    state: present
    controller_config_file: "~/tower_cli.cfg"
- name: Add twilio notification
  notification_template:
    name: twilio notification
    notification_type: twilio
    notification_configuration:
      account_token: a_token
      account_sid: a_sid
      from_number: '+15551112222'
      to_numbers:
        - '+15553334444'
    state: present
    controller_config_file: "~/tower_cli.cfg"
- name: Add PagerDuty notification
  notification_template:
    name: pagerduty notification
    notification_type: pagerduty
    notification_configuration:
      token: a_token
      subdomain: sub
      client_name: client
      service_key: a_key
    state: present
    controller_config_file: "~/tower_cli.cfg"
- name: Add IRC notification
  notification_template:
    name: irc notification
    notification_type: irc
    notification_configuration:
      nickname: controller
      password: s3cr3t
      targets:
        - user1
      port: 8080
      server: irc.example.com
      use_ssl: no
    state: present
    controller_config_file: "~/tower_cli.cfg"
- name: Delete notification
  notification_template:
    name: old notification
    state: absent
    controller_config_file: "~/tower_cli.cfg"
- name: Copy webhook notification
  notification_template:
    name: foo notification
    copy_from: email notification
    organization: Foo
