1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Added organization in the scm_credential get (#49884)

* Added organization in the scm_credential get

* Fallback looking for cred in project org

* Tests project with multi org credential

* Fixed CI issue

* Added changelog fragment
This commit is contained in:
Andrea Tartaglia 2018-12-19 12:01:12 +00:00 committed by AlanCoding
parent b11374157d
commit a37a18c0bf
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B

View File

@ -146,7 +146,11 @@ def main():
if scm_credential:
try:
cred_res = tower_cli.get_resource('credential')
cred = cred_res.get(name=scm_credential)
try:
cred = cred_res.get(name=scm_credential)
except (tower_cli.exceptions.MultipleResults) as multi_res_excinfo:
module.warn('Multiple credentials found for {0}, falling back looking in project organization'.format(scm_credential))
cred = cred_res.get(name=scm_credential, organization=org['id'])
scm_credential = cred['id']
except (exc.NotFound) as excinfo:
module.fail_json(msg='Failed to update project, credential not found: {0}'.format(scm_credential), changed=False)