ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.97k stars 3.41k forks source link

Unable to use CCP lookup plugin with empty webservice_id #13597

Closed obaranov closed 1 year ago

obaranov commented 1 year ago

Please confirm the following

Bug Summary

When job uses the CyberArk Central Credential Provider Lookup credential plugin with an empty web service id, it fails with the exception:

Traceback (most recent call last):
  File "/awx_devel/awx/main/tasks/jobs.py", line 508, in run
    args = self.build_args(self.instance, private_data_dir, passwords)
  File "/awx_devel/awx/main/tasks/jobs.py", line 941, in build_args
    ssh_username = creds.get_input('username', default='')
  File "/awx_devel/awx/main/models/credential/__init__.py", line 275, in get_input
    return self._get_dynamic_input(field_name)
  File "/awx_devel/awx/main/models/credential/__init__.py", line 309, in _get_dynamic_input
    return input_source.get_input_value()
  File "/awx_devel/awx/main/models/credential/__init__.py", line 1250, in get_input_value
    return backend(**backend_kwargs)
  File "/awx_devel/awx/main/credential_plugins/aim.py", line 73, in aim_backend
    webservice_id = kwargs['webservice_id']
KeyError: 'webservice_id'

The issue is only reproducible if we create a CCP lookup credential using API and we do not provide the webservice_id key as the input. If you create CCP lookup with UI - everything works fine.

AWX version

devel

Select the relevant components

Installation method

docker development environment

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

  1. Create CyberArk Central Credential Provider Lookup credential. Do not provide the WebService ID value, keep it empty. I used API to create credetnail and the webservice_id was missing in the inputs:
inputs = {
            'url': url,
            'app_id': app_id,
            'client_key': client_key,
            'client_cert': client_cert,
            'verify': verify
}

payload = factories.credential.payload(
    name=fauxfactory.gen_utf8(),
    description=fauxfactory.gen_utf8(),
    credential_type=cred_type,
    inputs=inputs
)
  1. Create Machine credential that uses the CCP lookup credential. Set proper Object query.
  2. Create Job Template that uses this credential. Run the job.

Expected results

The lookup should use default webservice id: AIMWebService

Actual results

Exception occured. See description.

Additional information

No response

obaranov commented 1 year ago

@infamousjoeg can you please take a look when you have some time?

infamousjoeg commented 1 year ago

@obaranov I am unable to recreate this issue on the devel branch.

obaranov commented 1 year ago

@obaranov I am unable to recreate this issue on the devel branch.

This only happens when I use API call directly without providing the webservice_id at all. UI works well, since it puts the webservice_id='' to the call.