Fixing azure_rm_postgresqldatabase force_update parameter (#52388)
(cherry picked from commit 8422e23533
)
This commit is contained in:
parent
40055b4507
commit
474d76c0dd
3 changed files with 39 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- azure_rm_postgresqldatabase - fix force_update bug (https://github.com/ansible/ansible/issues/50978).
|
|
@ -145,6 +145,7 @@ class AzureRMDatabases(AzureRMModuleBase):
|
||||||
self.resource_group = None
|
self.resource_group = None
|
||||||
self.server_name = None
|
self.server_name = None
|
||||||
self.name = None
|
self.name = None
|
||||||
|
self.force_update = None
|
||||||
self.parameters = dict()
|
self.parameters = dict()
|
||||||
|
|
||||||
self.results = dict(changed=False)
|
self.results = dict(changed=False)
|
||||||
|
@ -199,6 +200,7 @@ class AzureRMDatabases(AzureRMModuleBase):
|
||||||
if not self.check_mode:
|
if not self.check_mode:
|
||||||
self.delete_postgresqldatabase()
|
self.delete_postgresqldatabase()
|
||||||
else:
|
else:
|
||||||
|
self.fail("Database properties cannot be updated without setting 'force_update' option")
|
||||||
self.to_do = Actions.NoAction
|
self.to_do = Actions.NoAction
|
||||||
|
|
||||||
if (self.to_do == Actions.Create) or (self.to_do == Actions.Update):
|
if (self.to_do == Actions.Create) or (self.to_do == Actions.Update):
|
||||||
|
|
|
@ -160,6 +160,8 @@
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
server_name: postgresqlsrv{{ rpfx }}
|
server_name: postgresqlsrv{{ rpfx }}
|
||||||
name: testdatabase
|
name: testdatabase
|
||||||
|
charset: UTF8
|
||||||
|
collation: English_United States.1252
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: output
|
register: output
|
||||||
- name: Assert the resource instance is well created
|
- name: Assert the resource instance is well created
|
||||||
|
@ -172,6 +174,8 @@
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
server_name: postgresqlsrv{{ rpfx }}
|
server_name: postgresqlsrv{{ rpfx }}
|
||||||
name: testdatabase
|
name: testdatabase
|
||||||
|
charset: UTF8
|
||||||
|
collation: English_United States.1252
|
||||||
register: output
|
register: output
|
||||||
- name: Assert the resource instance is well created
|
- name: Assert the resource instance is well created
|
||||||
assert:
|
assert:
|
||||||
|
@ -184,6 +188,8 @@
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
server_name: postgresqlsrv{{ rpfx }}
|
server_name: postgresqlsrv{{ rpfx }}
|
||||||
name: testdatabase
|
name: testdatabase
|
||||||
|
charset: UTF8
|
||||||
|
collation: English_United States.1252
|
||||||
register: output
|
register: output
|
||||||
- name: Assert the state has not changed
|
- name: Assert the state has not changed
|
||||||
assert:
|
assert:
|
||||||
|
@ -191,6 +197,35 @@
|
||||||
- output.changed == false
|
- output.changed == false
|
||||||
- output.name == 'testdatabase'
|
- 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
|
- name: Create second instance of PostgreSQL Database
|
||||||
azure_rm_postgresqldatabase:
|
azure_rm_postgresqldatabase:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
|
|
Loading…
Reference in a new issue