From 7186234a84dc481768951dc81038c7e48a70453b Mon Sep 17 00:00:00 2001 From: Xijun Dai Date: Tue, 11 Dec 2018 09:09:29 +0800 Subject: [PATCH] Fix Unicode-objects must be encoded before hashing (#46608) --- lib/ansible/plugins/inventory/azure_rm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/inventory/azure_rm.py b/lib/ansible/plugins/inventory/azure_rm.py index edc4017451d..6beef88a2f2 100644 --- a/lib/ansible/plugins/inventory/azure_rm.py +++ b/lib/ansible/plugins/inventory/azure_rm.py @@ -156,7 +156,7 @@ from ansible.module_utils.six import iteritems from ansible.module_utils.azure_rm_common import AzureRMAuth from ansible.errors import AnsibleParserError, AnsibleError from ansible.module_utils.parsing.convert_bool import boolean -from ansible.module_utils._text import to_native +from ansible.module_utils._text import to_native, to_bytes from itertools import chain from msrest import ServiceClient, Serializer, Deserializer from msrestazure import AzureConfiguration @@ -450,7 +450,7 @@ class AzureHost(object): self.nics = [] # Azure often doesn't provide a globally-unique filename, so use resource name + a chunk of ID hash - self.default_inventory_hostname = '{0}_{1}'.format(vm_model['name'], hashlib.sha1(vm_model['id']).hexdigest()[0:4]) + self.default_inventory_hostname = '{0}_{1}'.format(vm_model['name'], hashlib.sha1(to_bytes(vm_model['id'])).hexdigest()[0:4]) self._hostvars = {}