mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #16559 from chouseknecht/azure-rc5
Fix authentication via params and env variables.
This commit is contained in:
commit
54db1df244
2 changed files with 8 additions and 8 deletions
|
@ -8,12 +8,12 @@ Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Using the Azure Resource Manager modules requires having `Azure Python SDK <https://github.com/Azure/azure-sdk-for-python>`_
|
Using the Azure Resource Manager modules requires having `Azure Python SDK <https://github.com/Azure/azure-sdk-for-python>`_
|
||||||
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:
|
SDK is via pip:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ pip install "azure>=2.0.0rc4"
|
$ pip install "azure==2.0.0rc5"
|
||||||
|
|
||||||
|
|
||||||
Authenticating with Azure
|
Authenticating with Azure
|
||||||
|
|
|
@ -312,21 +312,21 @@ class AzureRMModuleBase(object):
|
||||||
except:
|
except:
|
||||||
pass
|
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 credentials
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _get_env_credentials(self):
|
def _get_env_credentials(self):
|
||||||
env_credentials = dict()
|
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)
|
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'])
|
credentials = self._get_profile(env_credentials['profile'])
|
||||||
return credentials
|
return credentials
|
||||||
|
|
||||||
if env_credentials['client_id'] is not None:
|
if env_credentials.get('subscription_id') is not None:
|
||||||
return env_credentials
|
return env_credentials
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
@ -338,7 +338,7 @@ class AzureRMModuleBase(object):
|
||||||
self.log('Getting credentials')
|
self.log('Getting credentials')
|
||||||
|
|
||||||
arg_credentials = dict()
|
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)
|
arg_credentials[attribute] = params.get(attribute, None)
|
||||||
|
|
||||||
# try module params
|
# try module params
|
||||||
|
@ -347,7 +347,7 @@ class AzureRMModuleBase(object):
|
||||||
credentials = self._get_profile(arg_credentials['profile'])
|
credentials = self._get_profile(arg_credentials['profile'])
|
||||||
return credentials
|
return credentials
|
||||||
|
|
||||||
if arg_credentials['client_id'] is not None:
|
if arg_credentials['subscription_id']:
|
||||||
self.log('Received credentials from parameters.')
|
self.log('Received credentials from parameters.')
|
||||||
return arg_credentials
|
return arg_credentials
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue