From c71a939b08ef61f9964b8a5b3cc5ba6a23e8e320 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Sat, 2 Jul 2016 21:27:00 -0400 Subject: [PATCH] Fix authentication via params and env vars. Update guide to RC5. --- docsite/rst/guide_azure.rst | 4 ++-- lib/ansible/module_utils/azure_rm_common.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docsite/rst/guide_azure.rst b/docsite/rst/guide_azure.rst index 527d706868c..3e98ed70d14 100644 --- a/docsite/rst/guide_azure.rst +++ b/docsite/rst/guide_azure.rst @@ -8,12 +8,12 @@ Requirements ------------ Using the Azure Resource Manager modules requires having `Azure Python SDK `_ -installed on the host running Ansible. You will need to have >= v2.0.0RC4 installed. The simplest way to install the +installed on the host running Ansible. You will need to have == v2.0.0RC5 installed. The simplest way to install the SDK is via pip: .. code-block:: bash - $ pip install "azure>=2.0.0rc4" + $ pip install "azure==2.0.0rc5" Authenticating with Azure diff --git a/lib/ansible/module_utils/azure_rm_common.py b/lib/ansible/module_utils/azure_rm_common.py index 5f41d6ab1b4..c455db7706c 100644 --- a/lib/ansible/module_utils/azure_rm_common.py +++ b/lib/ansible/module_utils/azure_rm_common.py @@ -312,21 +312,21 @@ class AzureRMModuleBase(object): except: pass - if credentials.get('client_id') is not None or credentials.get('ad_user') is not None: + if credentials.get('subscription_id'): return credentials return None def _get_env_credentials(self): env_credentials = dict() - for attribute, env_variable in AZURE_CREDENTIAL_ENV_MAPPING.items(): + for attribute, env_variable in AZURE_CREDENTIAL_ENV_MAPPING.iteritems(): env_credentials[attribute] = os.environ.get(env_variable, None) - if env_credentials['profile'] is not None: + if env_credentials['profile']: credentials = self._get_profile(env_credentials['profile']) return credentials - if env_credentials['client_id'] is not None: + if env_credentials.get('subscription_id') is not None: return env_credentials return None @@ -338,7 +338,7 @@ class AzureRMModuleBase(object): self.log('Getting credentials') arg_credentials = dict() - for attribute, env_variable in AZURE_CREDENTIAL_ENV_MAPPING.items(): + for attribute, env_variable in AZURE_CREDENTIAL_ENV_MAPPING.iteritems(): arg_credentials[attribute] = params.get(attribute, None) # try module params @@ -347,7 +347,7 @@ class AzureRMModuleBase(object): credentials = self._get_profile(arg_credentials['profile']) return credentials - if arg_credentials['client_id'] is not None: + if arg_credentials['subscription_id']: self.log('Received credentials from parameters.') return arg_credentials