diff --git a/lib/ansible/module_utils/azure_rm_common.py b/lib/ansible/module_utils/azure_rm_common.py index 1a508183996..e8170261052 100644 --- a/lib/ansible/module_utils/azure_rm_common.py +++ b/lib/ansible/module_utils/azure_rm_common.py @@ -839,6 +839,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/lib/ansible/modules/cloud/azure/azure_rm_containerinstance.py b/lib/ansible/modules/cloud/azure/azure_rm_containerinstance.py index 4022c1fba98..78478d88429 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_containerinstance.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_containerinstance.py @@ -50,7 +50,7 @@ options: choices: - public - none - default: None + default: 'none' ports: description: - List of ports exposed within the container group. @@ -93,7 +93,7 @@ options: description: - Force update of existing container instance. Any update will result in deletion and recreation of existing containers. type: bool - default: False + default: 'no' extends_documentation_fragment: - azure @@ -145,6 +145,7 @@ from ansible.module_utils.azure_rm_common import AzureRMModuleBase try: from msrestazure.azure_exceptions import CloudError + from msrestazure.azure_operation import AzureOperationPoller from azure.mgmt.containerinstance import ContainerInstanceManagementClient except ImportError: # This is handled in azure_rm_common @@ -383,6 +384,9 @@ class AzureRMContainerInstance(AzureRMModuleBase): container_group_name=self.name, container_group=parameters) + if isinstance(response, AzureOperationPoller): + response = self.get_poller_result(response) + return response.as_dict() def delete_containerinstance(self): diff --git a/lib/ansible/modules/cloud/azure/azure_rm_mysqldatabase.py b/lib/ansible/modules/cloud/azure/azure_rm_mysqldatabase.py index 1c331a4818a..f4bb4539cd8 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_mysqldatabase.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_mysqldatabase.py @@ -88,9 +88,9 @@ import time from ansible.module_utils.azure_rm_common import AzureRMModuleBase try: - from msrestazure.azure_exceptions import CloudError - from msrestazure.azure_operation import AzureOperationPoller from azure.mgmt.rdbms.mysql import MySQLManagementClient + from msrestazure.azure_exceptions import CloudError + from msrest.polling import LROPoller from msrest.serialization import Model except ImportError: # This is handled in azure_rm_common @@ -240,7 +240,7 @@ class AzureRMDatabases(AzureRMModuleBase): server_name=self.server_name, database_name=self.name, parameters=self.parameters) - if isinstance(response, AzureOperationPoller): + if isinstance(response, LROPoller): response = self.get_poller_result(response) except CloudError as exc: diff --git a/lib/ansible/modules/cloud/azure/azure_rm_mysqlserver.py b/lib/ansible/modules/cloud/azure/azure_rm_mysqlserver.py index a6c0a696941..111dadb510e 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_mysqlserver.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_mysqlserver.py @@ -124,9 +124,9 @@ import time from ansible.module_utils.azure_rm_common import AzureRMModuleBase try: - from msrestazure.azure_exceptions import CloudError - from msrestazure.azure_operation import AzureOperationPoller from azure.mgmt.rdbms.mysql import MySQLManagementClient + from msrestazure.azure_exceptions import CloudError + from msrest.polling import LROPoller from msrest.serialization import Model except ImportError: # This is handled in azure_rm_common @@ -303,10 +303,15 @@ class AzureRMServers(AzureRMModuleBase): self.log("Creating / Updating the MySQL Server instance {0}".format(self.name)) try: - response = self.mgmt_client.servers.create_or_update(resource_group_name=self.resource_group, - server_name=self.name, - parameters=self.parameters) - if isinstance(response, AzureOperationPoller): + if (self.to_do == Actions.Create): + response = self.mgmt_client.servers.create(resource_group_name=self.resource_group, + server_name=self.name, + parameters=self.parameters) + else: + response = self.mgmt_client.servers.update(resource_group_name=self.resource_group, + server_name=self.name, + parameters=self.parameters) + if isinstance(response, LROPoller): response = self.get_poller_result(response) except CloudError as exc: diff --git a/lib/ansible/modules/cloud/azure/azure_rm_postgresqldatabase.py b/lib/ansible/modules/cloud/azure/azure_rm_postgresqldatabase.py index c0b7e5e122c..a10724c7ab7 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_postgresqldatabase.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_postgresqldatabase.py @@ -88,9 +88,9 @@ import time from ansible.module_utils.azure_rm_common import AzureRMModuleBase try: - from msrestazure.azure_exceptions import CloudError - from msrestazure.azure_operation import AzureOperationPoller from azure.mgmt.rdbms.postgresql import PostgreSQLManagementClient + from msrestazure.azure_exceptions import CloudError + from msrest.polling import LROPoller from msrest.serialization import Model except ImportError: # This is handled in azure_rm_common @@ -240,7 +240,7 @@ class AzureRMDatabases(AzureRMModuleBase): server_name=self.server_name, database_name=self.name, parameters=self.parameters) - if isinstance(response, AzureOperationPoller): + if isinstance(response, LROPoller): response = self.get_poller_result(response) except CloudError as exc: diff --git a/lib/ansible/modules/cloud/azure/azure_rm_postgresqlserver.py b/lib/ansible/modules/cloud/azure/azure_rm_postgresqlserver.py index bc0b5322fc7..dc5ba866e51 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_postgresqlserver.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_postgresqlserver.py @@ -124,9 +124,9 @@ import time from ansible.module_utils.azure_rm_common import AzureRMModuleBase try: - from msrestazure.azure_exceptions import CloudError - from msrestazure.azure_operation import AzureOperationPoller from azure.mgmt.rdbms.postgresql import PostgreSQLManagementClient + from msrestazure.azure_exceptions import CloudError + from msrest.polling import LROPoller from msrest.serialization import Model except ImportError: # This is handled in azure_rm_common @@ -311,7 +311,7 @@ class AzureRMServers(AzureRMModuleBase): response = self.mgmt_client.servers.update(resource_group_name=self.resource_group, server_name=self.name, parameters=self.parameters) - if isinstance(response, AzureOperationPoller): + if isinstance(response, LROPoller): response = self.get_poller_result(response) except CloudError as exc: diff --git a/packaging/requirements/requirements-azure.txt b/packaging/requirements/requirements-azure.txt index ce6691b7900..b2b0ed56399 100644 --- a/packaging/requirements/requirements-azure.txt +++ b/packaging/requirements/requirements-azure.txt @@ -6,8 +6,8 @@ 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 +msrest==0.4.29 +msrestazure==0.4.31 azure-mgmt-dns>=1.0.1,<2 azure-mgmt-keyvault>=0.40.0,<0.41 azure-mgmt-batch>=4.1.0,<5 @@ -15,5 +15,5 @@ azure-mgmt-sql>=0.7.1,<0.8 azure-mgmt-web>=0.32.0,<0.33 azure-mgmt-containerservice>=2.0.0,<3.0.0 azure-mgmt-containerregistry>=1.0.1 -azure-mgmt-rdbms>=0.2.0rc1,<0.3.0 -azure-mgmt-containerinstance>=0.3.1 +azure-mgmt-rdbms==1.2.0 +azure-mgmt-containerinstance==0.4.0 diff --git a/test/integration/targets/azure_rm_containerinstance/tasks/main.yml b/test/integration/targets/azure_rm_containerinstance/tasks/main.yml index f9a38320f3a..ef85a23f751 100644 --- a/test/integration/targets/azure_rm_containerinstance/tasks/main.yml +++ b/test/integration/targets/azure_rm_containerinstance/tasks/main.yml @@ -14,18 +14,18 @@ ports: - 80 - 81 - - name: mycontainer2 - image: httpd - memory: 1.5 register: output +- debug: + var: output + - name: Assert the container instance is well created assert: that: - output.changed - - output.provisioning_state == 'Creating' + - output.provisioning_state == 'Succeeded' -- name: Create sample container instance +- name: Create sample container instance -- same parameters azure_rm_containerinstance: resource_group: "{{ resource_group }}" name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}" @@ -41,9 +41,6 @@ ports: - 80 - 81 - - name: mycontainer2 - image: httpd - memory: 1.5 register: output - name: Assert the container instance is well created @@ -51,7 +48,7 @@ that: - output.changed == False -- name: Create sample container instance +- name: Create sample container instance -- force update azure_rm_containerinstance: resource_group: "{{ resource_group }}" name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}" @@ -74,7 +71,7 @@ assert: that: - output.changed - - output.provisioning_state == 'Creating' + - output.provisioning_state == 'Succeeded' - name: Remove container instance azure_rm_containerinstance: diff --git a/test/integration/targets/azure_rm_mysqldatabase/tasks/main.yml b/test/integration/targets/azure_rm_mysqldatabase/tasks/main.yml index cebe2796a83..ca6ad1f654f 100644 --- a/test/integration/targets/azure_rm_mysqldatabase/tasks/main.yml +++ b/test/integration/targets/azure_rm_mysqldatabase/tasks/main.yml @@ -8,8 +8,8 @@ resource_group: "{{ resource_group }}" name: mysqlsrv{{ rpfx }} sku: - name: MYSQLB50 - tier: basic + name: GP_Gen4_2 + tier: GeneralPurpose location: westus storage_mb: 51200 version: 5.6 diff --git a/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml b/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml index 05af75bfbdb..27f98efb2e2 100644 --- a/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml +++ b/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml @@ -8,8 +8,8 @@ resource_group: "{{ resource_group }}" name: mysqlsrv{{ rpfx }} sku: - name: MYSQLB50 - tier: basic + name: GP_Gen4_2 + tier: GeneralPurpose location: westus storage_mb: 51200 version: 5.6 @@ -28,8 +28,8 @@ resource_group: "{{ resource_group }}" name: mysqlsrv{{ rpfx }} sku: - name: MYSQLB50 - tier: basic + name: GP_Gen4_2 + tier: GeneralPurpose location: westus storage_mb: 51200 version: 5.6 @@ -48,8 +48,8 @@ resource_group: "{{ resource_group }}" name: mysqlsrv{{ rpfx }} sku: - name: MYSQLB50 - tier: basic + name: GP_Gen4_2 + tier: GeneralPurpose location: westus storage_mb: 51200 version: 5.6 diff --git a/test/integration/targets/azure_rm_postgresqldatabase/tasks/main.yml b/test/integration/targets/azure_rm_postgresqldatabase/tasks/main.yml index e9b1308d049..24e26d11175 100644 --- a/test/integration/targets/azure_rm_postgresqldatabase/tasks/main.yml +++ b/test/integration/targets/azure_rm_postgresqldatabase/tasks/main.yml @@ -8,8 +8,8 @@ resource_group: "{{ resource_group }}" name: postgresqlsrv{{ rpfx }} sku: - name: PGSQLS100 - tier: basic + name: GP_Gen4_2 + tier: GeneralPurpose location: westus storage_mb: 51200 enforce_ssl: True diff --git a/test/integration/targets/azure_rm_postgresqlserver/tasks/main.yml b/test/integration/targets/azure_rm_postgresqlserver/tasks/main.yml index bc2706ef81c..53a3d2d7973 100644 --- a/test/integration/targets/azure_rm_postgresqlserver/tasks/main.yml +++ b/test/integration/targets/azure_rm_postgresqlserver/tasks/main.yml @@ -8,8 +8,8 @@ resource_group: "{{ resource_group }}" name: postgresqlsrv{{ rpfx }} sku: - name: PGSQLS100 - tier: basic + name: GP_Gen4_2 + tier: GeneralPurpose location: westus storage_mb: 51200 enforce_ssl: True @@ -27,8 +27,8 @@ resource_group: "{{ resource_group }}" name: postgresqlsrv{{ rpfx }} sku: - name: PGSQLS100 - tier: basic + name: GP_Gen4_2 + tier: GeneralPurpose location: westus storage_mb: 51200 enforce_ssl: True @@ -46,8 +46,8 @@ resource_group: "{{ resource_group }}" name: postgresqlsrv{{ rpfx }} sku: - name: PGSQLS100 - tier: basic + name: GP_Gen4_2 + tier: GeneralPurpose location: westus storage_mb: 51200 enforce_ssl: True diff --git a/test/runner/requirements/integration.cloud.azure.txt b/test/runner/requirements/integration.cloud.azure.txt index ce6691b7900..b2b0ed56399 100644 --- a/test/runner/requirements/integration.cloud.azure.txt +++ b/test/runner/requirements/integration.cloud.azure.txt @@ -6,8 +6,8 @@ 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 +msrest==0.4.29 +msrestazure==0.4.31 azure-mgmt-dns>=1.0.1,<2 azure-mgmt-keyvault>=0.40.0,<0.41 azure-mgmt-batch>=4.1.0,<5 @@ -15,5 +15,5 @@ azure-mgmt-sql>=0.7.1,<0.8 azure-mgmt-web>=0.32.0,<0.33 azure-mgmt-containerservice>=2.0.0,<3.0.0 azure-mgmt-containerregistry>=1.0.1 -azure-mgmt-rdbms>=0.2.0rc1,<0.3.0 -azure-mgmt-containerinstance>=0.3.1 +azure-mgmt-rdbms==1.2.0 +azure-mgmt-containerinstance==0.4.0