mirror of
https://github.com/ansible/awx.git
synced 2026-03-20 02:17:37 -02:30
address a few follow-up issues for Org -> Galaxy Credentials support
- add support for managing galaxy creds in the tower organization module - fix a minor serializer bug
This commit is contained in:
@@ -2695,6 +2695,7 @@ class CredentialSerializerCreate(CredentialSerializer):
|
|||||||
attrs['organization'] = attrs['team'].organization
|
attrs['organization'] = attrs['team'].organization
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
'credential_type' in attrs and
|
||||||
attrs['credential_type'].kind == 'galaxy' and
|
attrs['credential_type'].kind == 'galaxy' and
|
||||||
list(owner_fields) != ['organization']
|
list(owner_fields) != ['organization']
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -67,6 +67,11 @@ options:
|
|||||||
- list of notifications to send on start
|
- list of notifications to send on start
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
galaxy_credentials:
|
||||||
|
description:
|
||||||
|
- list of Ansible Galaxy credentials to associate to the organization
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
extends_documentation_fragment: awx.awx.auth
|
extends_documentation_fragment: awx.awx.auth
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@@ -86,6 +91,14 @@ EXAMPLES = '''
|
|||||||
custom_virtualenv: "/var/lib/awx/venv/foo-venv/"
|
custom_virtualenv: "/var/lib/awx/venv/foo-venv/"
|
||||||
state: present
|
state: present
|
||||||
tower_config_file: "~/tower_cli.cfg"
|
tower_config_file: "~/tower_cli.cfg"
|
||||||
|
|
||||||
|
- name: Create tower organization that pulls content from galaxy.ansible.com
|
||||||
|
tower_organization:
|
||||||
|
name: "Foo"
|
||||||
|
state: present
|
||||||
|
galaxy_credentials:
|
||||||
|
- Ansible Galaxy
|
||||||
|
tower_config_file: "~/tower_cli.cfg"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ..module_utils.tower_api import TowerAPIModule
|
from ..module_utils.tower_api import TowerAPIModule
|
||||||
@@ -102,6 +115,7 @@ def main():
|
|||||||
notification_templates_success=dict(type="list", elements='str'),
|
notification_templates_success=dict(type="list", elements='str'),
|
||||||
notification_templates_error=dict(type="list", elements='str'),
|
notification_templates_error=dict(type="list", elements='str'),
|
||||||
notification_templates_approvals=dict(type="list", elements='str'),
|
notification_templates_approvals=dict(type="list", elements='str'),
|
||||||
|
galaxy_credentials=dict(type="list", elements='str'),
|
||||||
state=dict(choices=['present', 'absent'], default='present'),
|
state=dict(choices=['present', 'absent'], default='present'),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -149,6 +163,12 @@ def main():
|
|||||||
for item in notifications_approval:
|
for item in notifications_approval:
|
||||||
association_fields['notification_templates_approvals'].append(module.resolve_name_to_id('notification_templates', item))
|
association_fields['notification_templates_approvals'].append(module.resolve_name_to_id('notification_templates', item))
|
||||||
|
|
||||||
|
galaxy_credentials = module.params.get('galaxy_credentials')
|
||||||
|
if galaxy_credentials is not None:
|
||||||
|
association_fields['galaxy_credentials'] = []
|
||||||
|
for item in galaxy_credentials:
|
||||||
|
association_fields['galaxy_credentials'].append(module.resolve_name_to_id('credentials', item))
|
||||||
|
|
||||||
# Create the data that gets sent for create and update
|
# Create the data that gets sent for create and update
|
||||||
org_fields = {'name': module.get_item_name(organization) if organization else name}
|
org_fields = {'name': module.get_item_name(organization) if organization else name}
|
||||||
if description is not None:
|
if description is not None:
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
- name: "Create a new organization"
|
- name: "Create a new organization"
|
||||||
tower_organization:
|
tower_organization:
|
||||||
name: "{{ org_name }}"
|
name: "{{ org_name }}"
|
||||||
|
galaxy_credentials:
|
||||||
|
- Ansible Galaxy
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
|||||||
Reference in New Issue
Block a user