From 1f5cda37b34abccc1f10331b9b0c234bfb324afb Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Fri, 15 Feb 2019 17:33:21 +0800 Subject: [PATCH] Fix for MySQL server update and storage_mb (#51661) --- .../51661-fixing-azure-mysql-parameters.yaml | 2 ++ .../cloud/azure/azure_rm_mysqlserver.py | 4 ++- .../azure_rm_mysqlserver/tasks/main.yml | 32 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/51661-fixing-azure-mysql-parameters.yaml diff --git a/changelogs/fragments/51661-fixing-azure-mysql-parameters.yaml b/changelogs/fragments/51661-fixing-azure-mysql-parameters.yaml new file mode 100644 index 00000000000..e4ee63134c0 --- /dev/null +++ b/changelogs/fragments/51661-fixing-azure-mysql-parameters.yaml @@ -0,0 +1,2 @@ +bugfixes: + - azure_rm_mysqlserver - fixed issues with passing parameters while updating existing server instance diff --git a/lib/ansible/modules/cloud/azure/azure_rm_mysqlserver.py b/lib/ansible/modules/cloud/azure/azure_rm_mysqlserver.py index 74141d820b6..d4840e3d16b 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_mysqlserver.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_mysqlserver.py @@ -228,7 +228,7 @@ class AzureRMServers(AzureRMModuleBase): elif key == "location": self.parameters["location"] = kwargs[key] elif key == "storage_mb": - self.parameters.setdefault("properties", {})["storage_mb"] = kwargs[key] + self.parameters.setdefault("properties", {}).setdefault("storage_profile", {})["storage_mb"] = kwargs[key] elif key == "version": self.parameters.setdefault("properties", {})["version"] = kwargs[key] elif key == "enforce_ssl": @@ -321,6 +321,8 @@ class AzureRMServers(AzureRMModuleBase): server_name=self.name, parameters=self.parameters) else: + # structure of parameters for update must be changed + self.parameters.update(self.parameters.pop("properties", {})) response = self.mysql_client.servers.update(resource_group_name=self.resource_group, server_name=self.name, parameters=self.parameters) diff --git a/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml b/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml index d89d0d4d2b2..43fc6cd5257 100644 --- a/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml +++ b/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml @@ -63,6 +63,38 @@ - output.changed == false - output.state == 'Ready' +- name: Update instance of MySQL Server, change storage size + azure_rm_mysqlserver: + resource_group: "{{ resource_group }}" + name: mysqlsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 128000 + version: 5.6 + enforce_ssl: True + admin_username: zimxyz + admin_password: Testpasswordxyz12! + register: output +- name: Assert the state has not changed + assert: + that: + - output.changed + - output.state == 'Ready' +- debug: + var: output + +- name: Gather facts MySQL Server + azure_rm_mysqlserver_facts: + resource_group: "{{ resource_group }}" + name: mysqlsrv{{ rpfx }} + register: output +- name: Assert that storage size is correct + assert: + that: + - output.servers[0]['storage_mb'] == 128000 + - name: Create second instance of MySQL Server azure_rm_mysqlserver: resource_group: "{{ resource_group }}"