From fa73abcf5da805b10a0c394b4b2300d62201ca65 Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Mon, 18 Feb 2019 14:20:30 +0800 Subject: [PATCH] fixing force_update in azure_rm_mysqldatabase (#52389) --- .../52389-mysqldatabase-fix-force-update.yaml | 2 ++ .../cloud/azure/azure_rm_mysqldatabase.py | 2 ++ .../azure_rm_mysqlserver/tasks/main.yml | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 changelogs/fragments/52389-mysqldatabase-fix-force-update.yaml diff --git a/changelogs/fragments/52389-mysqldatabase-fix-force-update.yaml b/changelogs/fragments/52389-mysqldatabase-fix-force-update.yaml new file mode 100644 index 00000000000..8fef766e690 --- /dev/null +++ b/changelogs/fragments/52389-mysqldatabase-fix-force-update.yaml @@ -0,0 +1,2 @@ +bugfixes: + - azure_rm_postgresqldatabase - fix force_update bug. \ No newline at end of file diff --git a/lib/ansible/modules/cloud/azure/azure_rm_mysqldatabase.py b/lib/ansible/modules/cloud/azure/azure_rm_mysqldatabase.py index 45fe0e8fb51..1e26a478627 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_mysqldatabase.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_mysqldatabase.py @@ -145,6 +145,7 @@ class AzureRMDatabases(AzureRMModuleBase): self.resource_group = None self.server_name = None self.name = None + self.force_update = None self.parameters = dict() self.results = dict(changed=False) @@ -199,6 +200,7 @@ class AzureRMDatabases(AzureRMModuleBase): if not self.check_mode: self.delete_mysqldatabase() else: + self.fail("Database properties cannot be updated without setting 'force_update' option") self.to_do = Actions.NoAction if (self.to_do == Actions.Create) or (self.to_do == Actions.Update): diff --git a/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml b/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml index 43fc6cd5257..576a1c79eac 100644 --- a/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml +++ b/test/integration/targets/azure_rm_mysqlserver/tasks/main.yml @@ -196,6 +196,8 @@ resource_group: "{{ resource_group }}" server_name: mysqlsrv{{ rpfx }} name: testdatabase + collation: latin1_swedish_ci + charset: latin1 register: output - name: Assert the resource instance is well created assert: @@ -208,6 +210,8 @@ resource_group: "{{ resource_group }}" server_name: mysqlsrv{{ rpfx }} name: testdatabase + collation: latin1_swedish_ci + charset: latin1 register: output - name: Assert the state has not changed assert: @@ -215,6 +219,35 @@ - output.changed == false - output.name == 'testdatabase' +- name: Try to update database without force_update + azure_rm_mysqldatabase: + resource_group: "{{ resource_group }}" + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + collation: latin1_czech_ci + charset: latin1 + ignore_errors: yes + register: output +- name: Assert that nothing has changed + assert: + that: + - output.changed == False + +- name: Update instance of database using force_update + azure_rm_mysqldatabase: + resource_group: "{{ resource_group }}" + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + collation: latin1_czech_ci + charset: latin1 + force_update: yes + register: output +- name: Assert the state has changed + assert: + that: + - output.changed + - output.name == 'testdatabase' + - name: Create second instance of MySQL Database azure_rm_mysqldatabase: resource_group: "{{ resource_group }}"