Fixing azure_rm_postgresqldatabase force_update parameter (#52388)

This commit is contained in:
Zim Kalinowski 2019-02-18 14:04:01 +08:00 committed by GitHub
parent 2daaf4eedd
commit 8422e23533
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- azure_rm_postgresqldatabase - fix force_update bug (https://github.com/ansible/ansible/issues/50978).

View file

@ -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_postgresqldatabase()
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):

View file

@ -179,6 +179,8 @@
resource_group: "{{ resource_group }}"
server_name: postgresqlsrv{{ rpfx }}
name: testdatabase
charset: UTF8
collation: English_United States.1252
check_mode: yes
register: output
- name: Assert the resource instance is well created
@ -191,6 +193,8 @@
resource_group: "{{ resource_group }}"
server_name: postgresqlsrv{{ rpfx }}
name: testdatabase
charset: UTF8
collation: English_United States.1252
register: output
- name: Assert the resource instance is well created
assert:
@ -203,6 +207,8 @@
resource_group: "{{ resource_group }}"
server_name: postgresqlsrv{{ rpfx }}
name: testdatabase
charset: UTF8
collation: English_United States.1252
register: output
- name: Assert the state has not changed
assert:
@ -210,6 +216,35 @@
- output.changed == false
- output.name == 'testdatabase'
- name: Try to update PostgreSQL Database without force_update
azure_rm_postgresqldatabase:
resource_group: "{{ resource_group }}"
server_name: postgresqlsrv{{ rpfx }}
name: testdatabase
charset: WIN1252
collation: SQL_Latin1_General_CP1_CS_AS
ignore_errors: yes
register: output
- name: Assert that nothing has changed
assert:
that:
- output.changed == False
- name: Try to update PostgreSQL Database with force_update
azure_rm_postgresqldatabase:
resource_group: "{{ resource_group }}"
server_name: postgresqlsrv{{ rpfx }}
name: testdatabase
charset: WIN1252
collation: SQL_Latin1_General_CP1_CS_AS
force_update: yes
register: output
- name: Assert the state has changed
assert:
that:
- output.changed
- output.name == 'testdatabase'
- name: Create second instance of PostgreSQL Database
azure_rm_postgresqldatabase:
resource_group: "{{ resource_group }}"