Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the type of a credential results in duplicate creation #15429

Open
Basti117 opened this issue Aug 8, 2024 · 0 comments
Open

Changing the type of a credential results in duplicate creation #15429

Basti117 opened this issue Aug 8, 2024 · 0 comments

Comments

@Basti117
Copy link

Basti117 commented Aug 8, 2024

Hi everybody,
I am currently facing the issue, that if i change the type of a credential, a credential with the same name (but with the new type) is created as duplicate. This causes errors in further processing when the name of this credential is referenced (e. g. in a job template configuration).
I think that the root cause of this issue is located in the following code snippet:

cred_type_id = module.resolve_name_to_id('credential_types', credential_type)
if organization:
org_id = module.resolve_name_to_id('organizations', organization)
# Attempt to look up the object based on the provided name, credential type and optional organization
lookup_data = {
'credential_type': cred_type_id,
}
# Create a copy of lookup data for copying without org.
copy_lookup_data = lookup_data
if organization:
lookup_data['organization'] = org_id
credential = module.get_one('credentials', name_or_id=name, check_exists=(state == 'exists'), **{'data': lookup_data})

If i understand these lines correctly, the lookup, if a credential already exists, is based on three parameters (name, credential type and organization). The ansible automation platform does not return a matching object because the credential type has changed and the collection expects that credentials are only the "same", if all of these three parameters match.
That brings me to my actual question:
Is this behavior actually intended and if that is the case, why is it exactly implemented like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant