Resolving comments on PR

Made notification type optional

Fixed examples to use notification_configuration

Fixed defaults for headers to prevent deprication warning

Removed default on messages
This commit is contained in:
John Westcott IV
2020-04-01 09:39:50 -04:00
committed by beeankha
parent b4cde80fa9
commit 8699a8fbc2
2 changed files with 81 additions and 89 deletions

View File

@@ -43,7 +43,6 @@ options:
notification_type: notification_type:
description: description:
- The type of notification to be sent. - The type of notification to be sent.
required: True
choices: choices:
- 'email' - 'email'
- 'grafana' - 'grafana'
@@ -64,149 +63,144 @@ options:
description: description:
- Optional custom messages for notification template. - Optional custom messages for notification template.
type: dict type: dict
default:
started:
success:
error:
workflow_approval:
username: username:
description: description:
- The mail server username. Required if I(notification_type=email). - The mail server username.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
sender: sender:
description: description:
- The sender email address. Required if I(notification_type=email). - The sender email address.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
recipients: recipients:
description: description:
- The recipients email addresses. Required if I(notification_type=email). - The recipients email addresses.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: list type: list
elements: str elements: str
use_tls: use_tls:
description: description:
- The TLS trigger. Required if I(notification_type=email). - The TLS trigger.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: bool type: bool
host: host:
description: description:
- The mail server host. Required if I(notification_type=email). - The mail server host.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
use_ssl: use_ssl:
description: description:
- The SSL trigger. Required if I(notification_type=email) or if I(notification_type=irc). - The SSL trigger.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: bool type: bool
password: password:
description: description:
- The mail server password. Required if I(notification_type=email) or if I(notification_type=irc). - The mail server password.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
port: port:
description: description:
- The mail server port. Required if I(notification_type=email) or if I(notification_type=irc). - The mail server port.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: int type: int
channels: channels:
description: description:
- The destination Slack channels. Required if I(notification_type=slack). - The destination Slack channels.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: list type: list
elements: str elements: str
token: token:
description: description:
- The access token. Required if I(notification_type=slack), if I(notification_type=pagerduty) or if I(notification_type=hipchat). - The access token.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
account_token: account_token:
description: description:
- The Twillio account token. Required if I(notification_type=twillio). - The Twillio account token.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
from_number: from_number:
description: description:
- The source phone number. Required if I(notification_type=twillio). - The source phone number.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
to_numbers: to_numbers:
description: description:
- The destination phone numbers. Required if I(notification_type=twillio). - The destination phone numbers.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: list type: list
elements: str elements: str
account_sid: account_sid:
description: description:
- The Twillio account SID. Required if I(notification_type=twillio). - The Twillio account SID.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
subdomain: subdomain:
description: description:
- The PagerDuty subdomain. Required if I(notification_type=pagerduty). - The PagerDuty subdomain.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
service_key: service_key:
description: description:
- The PagerDuty service/integration API key. Required if I(notification_type=pagerduty). - The PagerDuty service/integration API key.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
client_name: client_name:
description: description:
- The PagerDuty client identifier. Required if I(notification_type=pagerduty). - The PagerDuty client identifier.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
message_from: message_from:
description: description:
- The label to be shown with the notification. Required if I(notification_type=hipchat). - The label to be shown with the notification.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
api_url: api_url:
description: description:
- The HipChat API URL. Required if I(notification_type=hipchat). - The HipChat API URL.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
color: color:
description: description:
- The notification color. Required if I(notification_type=hipchat). - The notification color.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
choices: ["yellow", "green", "red", "purple", "gray", "random"] choices: ["yellow", "green", "red", "purple", "gray", "random"]
type: str type: str
rooms: rooms:
description: description:
- HipChat rooms to send the notification to. Required if I(notification_type=hipchat). - HipChat rooms to send the notification to.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: list type: list
elements: str elements: str
notify: notify:
description: description:
- The notify channel trigger. Required if I(notification_type=hipchat). - The notify channel trigger.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: bool type: bool
url: url:
description: description:
- The target URL. Required if I(notification_type=webhook). - The target URL.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
headers: headers:
description: description:
- The HTTP headers as JSON string. Required if I(notification_type=webhook). - The HTTP headers as JSON string.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: dict type: dict
server: server:
description: description:
- The IRC server address. Required if I(notification_type=irc). - The IRC server address.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
nickname: nickname:
description: description:
- The IRC nickname. Required if I(notification_type=irc). - The IRC nickname.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: str type: str
targets: targets:
description: description:
- The destination channels or users. Required if I(notification_type=irc). - The destination channels or users.
- This parameter has been deprecated, please use 'notification_configuration' instead. - This parameter has been deprecated, please use 'notification_configuration' instead.
type: list type: list
elements: str elements: str
@@ -231,16 +225,17 @@ EXAMPLES = '''
name: slack notification name: slack notification
organization: Default organization: Default
notification_type: slack notification_type: slack
channels: notification_configuration:
- general channels:
token: cefda9e2be1f21d11cdd9452f5b7f97fda977f42 - general
token: cefda9e2be1f21d11cdd9452f5b7f97fda977f42
messages: messages:
started: started:
message: "{{ '{{' }} job_friendly_name {{' }}' }} {{ '{{' }} job.id {{' }}' }} started" message: "{{ '{{ job_friendly_name }}{{ job.id }} started' }}"
success: success:
message: "{{ '{{' }} job_friendly_name {{ '}}' }} completed in {{ '{{' }} job.elapsed {{ '}}' }} seconds" message: "{{ '{{ job_friendly_name }} completed in {{ job.elapsed }} seconds' }}"
error: error:
message: "{{ '{{' }} job_friendly_name {{ '}}' }} FAILED! Please look at {{ '{{' }} job.url {{ '}}' }}" message: "{{ '{{ job_friendly_name }} FAILED! Please look at {{ job.url }}' }}"
state: present state: present
tower_config_file: "~/tower_cli.cfg" tower_config_file: "~/tower_cli.cfg"
@@ -248,9 +243,10 @@ EXAMPLES = '''
tower_notification: tower_notification:
name: webhook notification name: webhook notification
notification_type: webhook notification_type: webhook
url: http://www.example.com/hook notification_configuration:
headers: url: http://www.example.com/hook
X-Custom-Header: value123 headers:
X-Custom-Header: value123
state: present state: present
tower_config_file: "~/tower_cli.cfg" tower_config_file: "~/tower_cli.cfg"
@@ -258,15 +254,16 @@ EXAMPLES = '''
tower_notification: tower_notification:
name: email notification name: email notification
notification_type: email notification_type: email
username: user notification_configuration:
password: s3cr3t username: user
sender: tower@example.com password: s3cr3t
recipients: sender: tower@example.com
- user1@example.com recipients:
host: smtp.example.com - user1@example.com
port: 25 host: smtp.example.com
use_tls: no port: 25
use_ssl: no use_tls: no
use_ssl: no
state: present state: present
tower_config_file: "~/tower_cli.cfg" tower_config_file: "~/tower_cli.cfg"
@@ -274,11 +271,12 @@ EXAMPLES = '''
tower_notification: tower_notification:
name: twilio notification name: twilio notification
notification_type: twilio notification_type: twilio
account_token: a_token notification_configuration:
account_sid: a_sid account_token: a_token
from_number: '+15551112222' account_sid: a_sid
to_numbers: from_number: '+15551112222'
- '+15553334444' to_numbers:
- '+15553334444'
state: present state: present
tower_config_file: "~/tower_cli.cfg" tower_config_file: "~/tower_cli.cfg"
@@ -286,10 +284,11 @@ EXAMPLES = '''
tower_notification: tower_notification:
name: pagerduty notification name: pagerduty notification
notification_type: pagerduty notification_type: pagerduty
token: a_token notification_configuration:
subdomain: sub token: a_token
client_name: client subdomain: sub
service_key: a_key client_name: client
service_key: a_key
state: present state: present
tower_config_file: "~/tower_cli.cfg" tower_config_file: "~/tower_cli.cfg"
@@ -297,13 +296,14 @@ EXAMPLES = '''
tower_notification: tower_notification:
name: hipchat notification name: hipchat notification
notification_type: hipchat notification_type: hipchat
token: a_token notification_configuration:
message_from: user1 token: a_token
api_url: https://hipchat.example.com message_from: user1
color: red api_url: https://hipchat.example.com
rooms: color: red
- room-A rooms:
notify: yes - room-A
notify: yes
state: present state: present
tower_config_file: "~/tower_cli.cfg" tower_config_file: "~/tower_cli.cfg"
@@ -311,23 +311,22 @@ EXAMPLES = '''
tower_notification: tower_notification:
name: irc notification name: irc notification
notification_type: irc notification_type: irc
nickname: tower notification_configuration:
password: s3cr3t nickname: tower
targets: password: s3cr3t
- user1 targets:
port: 8080 - user1
server: irc.example.com port: 8080
use_ssl: no server: irc.example.com
use_ssl: no
state: present state: present
tower_config_file: "~/tower_cli.cfg" tower_config_file: "~/tower_cli.cfg"
- name: Delete notification - name: Delete notification
tower_notification: tower_notification:
name: old notification name: old notification
notification_type: email
state: absent state: absent
tower_config_file: "~/tower_cli.cfg" tower_config_file: "~/tower_cli.cfg"
''' '''
@@ -354,12 +353,12 @@ def main():
new_name=dict(), new_name=dict(),
description=dict(), description=dict(),
organization=dict(), organization=dict(),
notification_type=dict(required=True, choices=[ notification_type=dict(choices=[
'email', 'grafana', 'hipchat', 'irc', 'mattermost', 'email', 'grafana', 'hipchat', 'irc', 'mattermost',
'pagerduty', 'rocketchat', 'slack', 'twilio', 'webhook' 'pagerduty', 'rocketchat', 'slack', 'twilio', 'webhook'
]), ]),
notification_configuration=dict(type='dict'), notification_configuration=dict(type='dict'),
messages=dict(type='dict', default={'started': None, 'success': None, 'error': None, 'workflow_approval': None}), messages=dict(type='dict'),
username=dict(), username=dict(),
sender=dict(), sender=dict(),
recipients=dict(type='list', elements='str'), recipients=dict(type='list', elements='str'),
@@ -383,7 +382,7 @@ def main():
rooms=dict(type='list', elements='str'), rooms=dict(type='list', elements='str'),
notify=dict(type='bool'), notify=dict(type='bool'),
url=dict(), url=dict(),
headers=dict(type='dict', default={}), headers=dict(type='dict'),
server=dict(), server=dict(),
nickname=dict(), nickname=dict(),
targets=dict(type='list', elements='str'), targets=dict(type='list', elements='str'),

View File

@@ -92,7 +92,6 @@
tower_notification: tower_notification:
name: "{{ slack_not }}" name: "{{ slack_not }}"
organization: Default organization: Default
notification_type: slack
state: absent state: absent
register: result register: result
@@ -135,7 +134,6 @@
tower_notification: tower_notification:
name: "{{ webhook_not }}" name: "{{ webhook_not }}"
organization: Default organization: Default
notification_type: webhook
state: absent state: absent
register: result register: result
@@ -168,7 +166,6 @@
tower_notification: tower_notification:
name: "{{ email_not }}" name: "{{ email_not }}"
organization: Default organization: Default
notification_type: email
state: absent state: absent
register: result register: result
@@ -197,7 +194,6 @@
tower_notification: tower_notification:
name: "{{ twillo_not }}" name: "{{ twillo_not }}"
organization: Default organization: Default
notification_type: twilio
state: absent state: absent
register: result register: result
@@ -225,7 +221,6 @@
tower_notification: tower_notification:
name: "{{ pd_not }}" name: "{{ pd_not }}"
organization: Default organization: Default
notification_type: pagerduty
state: absent state: absent
register: result register: result
@@ -256,7 +251,6 @@
tower_notification: tower_notification:
name: "{{ hipchat_not }}" name: "{{ hipchat_not }}"
organization: Default organization: Default
notification_type: hipchat
state: absent state: absent
register: result register: result
@@ -287,7 +281,6 @@
tower_notification: tower_notification:
name: "{{ irc_not }}" name: "{{ irc_not }}"
organization: Default organization: Default
notification_type: irc
state: absent state: absent
register: result register: result