use tenant in UserPassCredentials if set (#20751)
* use tenant in UserPassCredentials if set If you have multiple Tenants you need to set the tenant in https://github.com/Azure/msrestazure-for-python/blob/master/msrestazure/azure_active_directory.py otherwise the azure_rm.py call will fail. see: https://github.com/ansible/ansible/pull/20750 * fixed PEP8 failure
This commit is contained in:
parent
8e05d7d962
commit
2f81a28414
1 changed files with 5 additions and 1 deletions
|
@ -185,7 +185,11 @@ class AzureRMModuleBase(object):
|
||||||
secret=self.credentials['secret'],
|
secret=self.credentials['secret'],
|
||||||
tenant=self.credentials['tenant'])
|
tenant=self.credentials['tenant'])
|
||||||
elif self.credentials.get('ad_user') is not None and self.credentials.get('password') is not None:
|
elif self.credentials.get('ad_user') is not None and self.credentials.get('password') is not None:
|
||||||
self.azure_credentials = UserPassCredentials(self.credentials['ad_user'], self.credentials['password'])
|
tenant = self.credentials.get('tenant')
|
||||||
|
if tenant is not None:
|
||||||
|
self.azure_credentials = UserPassCredentials(self.credentials['ad_user'], self.credentials['password'], tenant=tenant)
|
||||||
|
else:
|
||||||
|
self.azure_credentials = UserPassCredentials(self.credentials['ad_user'], self.credentials['password'])
|
||||||
else:
|
else:
|
||||||
self.fail("Failed to authenticate with provided credentials. Some attributes were missing. "
|
self.fail("Failed to authenticate with provided credentials. Some attributes were missing. "
|
||||||
"Credentials must include client_id, secret and tenant or ad_user and password.")
|
"Credentials must include client_id, secret and tenant or ad_user and password.")
|
||||||
|
|
Loading…
Reference in a new issue