mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
update organizations and approvals
This commit is contained in:
parent
b41a55f297
commit
ca0130fc64
@ -56,6 +56,31 @@ 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_approvals:
|
||||
description:
|
||||
- list of notifications to send on start
|
||||
type: list
|
||||
elements: str
|
||||
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
|
||||
notification_templates_approvals:
|
||||
description:
|
||||
- list of notifications to send on start
|
||||
type: list
|
||||
elements: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
'''
|
||||
|
||||
@ -87,6 +112,10 @@ def main():
|
||||
description=dict(),
|
||||
custom_virtualenv=dict(),
|
||||
max_hosts=dict(type='int', default="0"),
|
||||
notification_templates_started=dict(type="list", elements='str'),
|
||||
notification_templates_success=dict(type="list", elements='str'),
|
||||
notification_templates_error=dict(type="list", elements='str'),
|
||||
notification_templates_approvals=dict(type="list", elements='str'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
)
|
||||
|
||||
@ -111,6 +140,32 @@ def main():
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
module.delete_if_needed(organization)
|
||||
# Attempt to look up associated field items the user specified.
|
||||
association_fields = {}
|
||||
|
||||
notifications_start = module.params.get('notification_templates_started')
|
||||
if notifications_start is not None:
|
||||
association_fields['notification_templates_started'] = []
|
||||
for item in notifications_start:
|
||||
association_fields['notification_templates_started'].append(module.resolve_name_to_id('notification_templates', item))
|
||||
|
||||
notifications_success = module.params.get('notification_templates_success')
|
||||
if notifications_success is not None:
|
||||
association_fields['notification_templates_success'] = []
|
||||
for item in notifications_success:
|
||||
association_fields['notification_templates_success'].append(module.resolve_name_to_id('notification_templates', item))
|
||||
|
||||
notifications_error = module.params.get('notification_templates_error')
|
||||
if notifications_error is not None:
|
||||
association_fields['notification_templates_error'] = []
|
||||
for item in notifications_error:
|
||||
association_fields['notification_templates_error'].append(module.resolve_name_to_id('notification_templates', item))
|
||||
|
||||
notifications_approval = module.params.get('notification_templates_approvals')
|
||||
if notifications_approval is not None:
|
||||
association_fields['notification_templates_approvals'] = []
|
||||
for item in notifications_approval:
|
||||
association_fields['notification_templates_approvals'].append(module.resolve_name_to_id('notification_templates', item))
|
||||
|
||||
# Create the data that gets sent for create and update
|
||||
org_fields = {'name': name}
|
||||
@ -122,7 +177,11 @@ def main():
|
||||
org_fields['max_hosts'] = max_hosts
|
||||
|
||||
# If the state was present and we can let the module build or update the existing organization, this will return on its own
|
||||
module.create_or_update_if_needed(organization, org_fields, endpoint='organizations', item_type='organization')
|
||||
module.create_or_update_if_needed(
|
||||
organization, org_fields,
|
||||
endpoint='organizations', item_type='organization'
|
||||
associations=association_fields,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@ -128,6 +128,11 @@ options:
|
||||
- list of notifications to send on error
|
||||
type: list
|
||||
elements: str
|
||||
notification_templates_approvals:
|
||||
description:
|
||||
- list of notifications to send on start
|
||||
type: list
|
||||
elements: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
'''
|
||||
|
||||
@ -173,6 +178,7 @@ def main():
|
||||
notification_templates_started=dict(type="list", elements='str'),
|
||||
notification_templates_success=dict(type="list", elements='str'),
|
||||
notification_templates_error=dict(type="list", elements='str'),
|
||||
notification_templates_approvals=dict(type="list", elements='str'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
)
|
||||
|
||||
@ -242,6 +248,12 @@ def main():
|
||||
for item in notifications_error:
|
||||
association_fields['notification_templates_error'].append(module.resolve_name_to_id('notification_templates', item))
|
||||
|
||||
notifications_approval = module.params.get('notification_templates_approvals')
|
||||
if notifications_approval is not None:
|
||||
association_fields['notification_templates_approvals'] = []
|
||||
for item in notifications_approval:
|
||||
association_fields['notification_templates_approvals'].append(module.resolve_name_to_id('notification_templates', item))
|
||||
|
||||
on_change = None
|
||||
new_spec = module.params.get('survey')
|
||||
if new_spec:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user