From c84e3e70ab908863fe332aceaaa840fb3088e0b3 Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Mon, 14 May 2018 11:46:45 +0800 Subject: [PATCH] location name (#40055) --- lib/ansible/module_utils/azure_rm_common.py | 5 +++++ lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/azure_rm_common.py b/lib/ansible/module_utils/azure_rm_common.py index c9b058412d..8cf3a3cbf0 100644 --- a/lib/ansible/module_utils/azure_rm_common.py +++ b/lib/ansible/module_utils/azure_rm_common.py @@ -176,6 +176,11 @@ def format_resource_id(val, subscription_id, namespace, types, resource_group): type=types, subscription=subscription_id) if not is_valid_resource_id(val) else val + +def normalize_location_name(name): + return name.replace(' ', '').lower() + + # FUTURE: either get this from the requirements file (if we can be sure it's always available at runtime) # or generate the requirements files from this so we only have one source of truth to maintain... AZURE_PKG_VERSIONS = { diff --git a/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py b/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py index 85063cf303..7a6b60897d 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py @@ -96,7 +96,7 @@ try: except ImportError: pass -from ansible.module_utils.azure_rm_common import AzureRMModuleBase +from ansible.module_utils.azure_rm_common import AzureRMModuleBase, normalize_location_name def resource_group_to_dict(rg): @@ -162,7 +162,7 @@ class AzureRMResourceGroup(AzureRMModuleBase): if update_tags: changed = True - if self.location and self.location != results['location']: + if self.location and normalize_location_name(self.location) != results['location']: self.fail("Resource group '{0}' already exists in location '{1}' and cannot be " "moved.".format(self.name, results['location'])) except CloudError: