diff options
author | Peter Hoffmann <ph@peter-hoffmann.com> | 2017-01-27 13:20:04 +0100 |
---|---|---|
committer | ansibot <ansibot@users.noreply.github.com> | 2017-08-18 01:10:25 -0400 |
commit | 6c9cb05cfd017d4988c09d4654447246850684f9 (patch) | |
tree | db46357941a4fa6c9957051d5a3dc8630a4086a2 /contrib/inventory/azure_rm.py | |
parent | e45d5b7e8ebc05fadb0f66f115722c5ae29246af (diff) | |
download | ansible-6c9cb05cfd017d4988c09d4654447246850684f9.tar.gz |
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.
Diffstat (limited to 'contrib/inventory/azure_rm.py')
-rwxr-xr-x | contrib/inventory/azure_rm.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/contrib/inventory/azure_rm.py b/contrib/inventory/azure_rm.py index 6c77f20f24..955a31d8a5 100755 --- a/contrib/inventory/azure_rm.py +++ b/contrib/inventory/azure_rm.py @@ -274,7 +274,11 @@ class AzureRM(object): secret=self.credentials['secret'], tenant=self.credentials['tenant']) 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: 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.") |