Support adding/removing notifications to job_templates

This commit is contained in:
Francois Herbert
2020-04-20 13:02:41 +12:00
parent 8f5afc83ce
commit 68a0bbe125
2 changed files with 93 additions and 0 deletions

View File

@@ -275,6 +275,21 @@ options:
- If value not set, will try environment variable C(TOWER_OAUTH_TOKEN) and then config files
type: str
version_added: "3.7"
notification_templates_started:
description:
- list of notifications to send on start
type: list
elements: str
notification_templates_success:
description:
- list of notifications to send on success
type: list
elements: str
notification_templates_error:
description:
- list of notifications to send on error
type: list
elements: str
extends_documentation_fragment: awx.awx.auth
@@ -365,6 +380,9 @@ def main():
webhook_service=dict(choices=['github', 'gitlab']),
webhook_credential=dict(),
labels=dict(type="list", elements='str'),
notification_templates_started=dict(type="list", elements='str'),
notification_templates_success=dict(type="list", elements='str'),
notification_templates_error=dict(type="list", elements='str'),
state=dict(choices=['present', 'absent'], default='present'),
)
@@ -441,6 +459,24 @@ def main():
for item in labels:
labels_ids.append(module.resolve_name_to_id('labels', item))
notifications_start = module.params.get('notification_templates_started')
notification_start_ids = []
if notifications_start is not None:
for item in notifications_start:
notification_start_ids.append(module.resolve_name_to_id('notification_templates', item))
notifications_success = module.params.get('notification_templates_success')
notification_success_ids = []
if notifications_success is not None:
for item in notifications_success:
notification_success_ids.append(module.resolve_name_to_id('notification_templates', item))
notifications_error = module.params.get('notification_templates_error')
notification_error_ids = []
if notifications_error is not None:
for item in notifications_error:
notification_error_ids.append(module.resolve_name_to_id('notification_templates', item))
on_change = None
new_spec = module.params.get('survey_spec')
if new_spec is not None:
@@ -465,6 +501,9 @@ def main():
associations={
'credentials': credentials_ids,
'labels': labels_ids,
'notification_templates_success': notification_success_ids,
'notification_templates_started': notification_start_ids,
'notification_templates_error': notification_error_ids
},
on_create=on_change, on_update=on_change,
)