From 980cdbe67931b30ab094a690bd2a42d945b0b27e Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Tue, 5 Jun 2018 11:47:34 -0700 Subject: [PATCH] pin azure deps to exact versions * added warnings for newer-than-expected versions * prevent passing api_version and profile for newer clients --- lib/ansible/module_utils/azure_rm_common.py | 18 ++++++---- packaging/requirements/requirements-azure.txt | 36 ++++++++++--------- .../requirements/integration.cloud.azure.txt | 36 ++++++++++--------- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/lib/ansible/module_utils/azure_rm_common.py b/lib/ansible/module_utils/azure_rm_common.py index 012f6f7e06..4597e46556 100644 --- a/lib/ansible/module_utils/azure_rm_common.py +++ b/lib/ansible/module_utils/azure_rm_common.py @@ -195,23 +195,23 @@ AZURE_PKG_VERSIONS = { }, 'ComputeManagementClient': { 'package_name': 'compute', - 'expected_version': '2.0.0' + 'expected_version': '2.1.0' }, 'ContainerInstanceManagementClient': { 'package_name': 'containerinstance', - 'expected_version': '0.3.1' + 'expected_version': '0.4.0' }, 'NetworkManagementClient': { 'package_name': 'network', - 'expected_version': '1.3.0' + 'expected_version': '1.7.1' }, 'ResourceManagementClient': { 'package_name': 'resource', - 'expected_version': '1.1.0' + 'expected_version': '1.2.2' }, 'DnsManagementClient': { 'package_name': 'dns', - 'expected_version': '1.0.1' + 'expected_version': '1.2.0' }, 'WebSiteManagementClient': { 'package_name': 'web', @@ -408,8 +408,11 @@ class AzureRMModuleBase(object): return expected_version = package_version.get('expected_version') if Version(client_version) < Version(expected_version): - self.fail("Installed azure-mgmt-{0} client version is {1}. The supported version is {2}. Try " + self.fail("Installed azure-mgmt-{0} client version is {1}. The minimum supported version is {2}. Try " "`pip install ansible[azure]`".format(client_name, client_version, expected_version)) + if Version(client_version) != Version(expected_version): + self.module.warn("Installed azure-mgmt-{0} client version is {1}. The expected version is {2}. Try " + "`pip install ansible[azure]`".format(client_name, client_version, expected_version)) def exec_module(self, **kwargs): self.fail("Error: {0} failed to implement exec_module method.".format(self.__class__.__name__)) @@ -945,6 +948,9 @@ class AzureRMModuleBase(object): profile_default_version = api_profile_dict.get('default_api_version', None) if api_version or profile_default_version: client_kwargs['api_version'] = api_version or profile_default_version + if 'profile' in client_kwargs: + # remove profile; only pass API version if specified + client_kwargs.pop('profile') client = client_type(**client_kwargs) diff --git a/packaging/requirements/requirements-azure.txt b/packaging/requirements/requirements-azure.txt index a4b61f8486..65fddf0958 100644 --- a/packaging/requirements/requirements-azure.txt +++ b/packaging/requirements/requirements-azure.txt @@ -1,19 +1,23 @@ packaging requests[security] -azure-mgmt-compute>=2.0.0,<3 -azure-mgmt-network>=1.3.0,<2 -azure-mgmt-storage>=1.5.0,<2 -azure-mgmt-resource>=1.1.0,<2 -azure-storage>=0.35.1,<0.36 -azure-cli-core>=2.0.12,<3 -msrest!=0.4.15 -msrestazure>=0.4.11,<0.5 -azure-mgmt-dns>=1.0.1,<2 -azure-mgmt-keyvault>=0.40.0,<0.41 -azure-mgmt-batch>=4.1.0,<5 -azure-mgmt-sql>=0.7.1,<0.8 -azure-mgmt-web>=0.32.0,<0.33 -azure-mgmt-containerservice>=3.0.1 -azure-mgmt-containerregistry>=1.0.1 -azure-mgmt-rdbms>=0.2.0rc1,<0.3.0 +azure-cli-core==2.0.35 +azure-cli-nspkg==3.0.2 +azure-common==1.1.11 +azure-mgmt-batch==4.1.0 +azure-mgmt-compute==2.1.0 azure-mgmt-containerinstance==0.4.0 +azure-mgmt-containerregistry==2.0.0 +azure-mgmt-containerservice==3.0.1 +azure-mgmt-dns==1.2.0 +azure-mgmt-keyvault==0.40.0 +azure-mgmt-network==1.7.1 +azure-mgmt-nspkg==2.0.0 +azure-mgmt-rdbms==0.2.0rc1 +azure-mgmt-resource==1.2.2 +azure-mgmt-sql==0.7.1 +azure-mgmt-storage==1.5.0 +azure-mgmt-web==0.32.0 +azure-nspkg==2.0.0 +azure-storage==0.35.1 +msrest==0.4.29 +msrestazure==0.4.31 diff --git a/test/runner/requirements/integration.cloud.azure.txt b/test/runner/requirements/integration.cloud.azure.txt index a4b61f8486..65fddf0958 100644 --- a/test/runner/requirements/integration.cloud.azure.txt +++ b/test/runner/requirements/integration.cloud.azure.txt @@ -1,19 +1,23 @@ packaging requests[security] -azure-mgmt-compute>=2.0.0,<3 -azure-mgmt-network>=1.3.0,<2 -azure-mgmt-storage>=1.5.0,<2 -azure-mgmt-resource>=1.1.0,<2 -azure-storage>=0.35.1,<0.36 -azure-cli-core>=2.0.12,<3 -msrest!=0.4.15 -msrestazure>=0.4.11,<0.5 -azure-mgmt-dns>=1.0.1,<2 -azure-mgmt-keyvault>=0.40.0,<0.41 -azure-mgmt-batch>=4.1.0,<5 -azure-mgmt-sql>=0.7.1,<0.8 -azure-mgmt-web>=0.32.0,<0.33 -azure-mgmt-containerservice>=3.0.1 -azure-mgmt-containerregistry>=1.0.1 -azure-mgmt-rdbms>=0.2.0rc1,<0.3.0 +azure-cli-core==2.0.35 +azure-cli-nspkg==3.0.2 +azure-common==1.1.11 +azure-mgmt-batch==4.1.0 +azure-mgmt-compute==2.1.0 azure-mgmt-containerinstance==0.4.0 +azure-mgmt-containerregistry==2.0.0 +azure-mgmt-containerservice==3.0.1 +azure-mgmt-dns==1.2.0 +azure-mgmt-keyvault==0.40.0 +azure-mgmt-network==1.7.1 +azure-mgmt-nspkg==2.0.0 +azure-mgmt-rdbms==0.2.0rc1 +azure-mgmt-resource==1.2.2 +azure-mgmt-sql==0.7.1 +azure-mgmt-storage==1.5.0 +azure-mgmt-web==0.32.0 +azure-nspkg==2.0.0 +azure-storage==0.35.1 +msrest==0.4.29 +msrestazure==0.4.31