1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Adding support for Azure MSI user-assigned identity (#54884)

If more than one user-assigned identity is assigned to a host, then an identifier is required to specify which credentials are retrieved.  This change uses the existing support for client_id to retrieve the user-assigned identity by client_id.
This commit is contained in:
Aaron D 2019-04-23 23:13:09 -07:00 committed by Zim Kalinowski
parent 35fdae7485
commit 204db4d044

View file

@ -1149,8 +1149,9 @@ class AzureRMAuth(object):
return None
def _get_msi_credentials(self, subscription_id_param=None):
credentials = MSIAuthentication()
def _get_msi_credentials(self, subscription_id_param=None, **kwargs):
client_id = kwargs.get('client_id', None)
credentials = MSIAuthentication(client_id=client_id)
subscription_id = subscription_id_param or os.environ.get(AZURE_CREDENTIAL_ENV_MAPPING['subscription_id'], None)
if not subscription_id:
try:
@ -1206,7 +1207,7 @@ class AzureRMAuth(object):
if auth_source == 'msi':
self.log('Retrieving credenitals from MSI')
return self._get_msi_credentials(arg_credentials['subscription_id'])
return self._get_msi_credentials(arg_credentials['subscription_id'], client_id=params.get('client_id', None))
if auth_source == 'cli':
if not HAS_AZURE_CLI_CORE: