mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Merge pull request #8121 from ryanpetrello/galaxy-cred-collection
address a few follow-up issues for Org -> Galaxy Credentials support Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
328b270c9f
@ -2695,6 +2695,7 @@ class CredentialSerializerCreate(CredentialSerializer):
|
||||
attrs['organization'] = attrs['team'].organization
|
||||
|
||||
if (
|
||||
'credential_type' in attrs and
|
||||
attrs['credential_type'].kind == 'galaxy' and
|
||||
list(owner_fields) != ['organization']
|
||||
):
|
||||
|
||||
@ -67,6 +67,11 @@ options:
|
||||
- list of notifications to send on start
|
||||
type: list
|
||||
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
|
||||
'''
|
||||
|
||||
@ -86,6 +91,14 @@ EXAMPLES = '''
|
||||
custom_virtualenv: "/var/lib/awx/venv/foo-venv/"
|
||||
state: present
|
||||
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
|
||||
@ -102,6 +115,7 @@ def main():
|
||||
notification_templates_success=dict(type="list", elements='str'),
|
||||
notification_templates_error=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'),
|
||||
)
|
||||
|
||||
@ -149,6 +163,12 @@ def main():
|
||||
for item in notifications_approval:
|
||||
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
|
||||
org_fields = {'name': module.get_item_name(organization) if organization else name}
|
||||
if description is not None:
|
||||
|
||||
@ -12,6 +12,8 @@
|
||||
- name: "Create a new organization"
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
galaxy_credentials:
|
||||
- Ansible Galaxy
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user