Skip to content

Commit

Permalink
Fix for PostgresSQL server update and storage_mb (ansible#51653)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zim Kalinowski authored Feb 15, 2019
1 parent 1f5cda3 commit 2f39605
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- azure_rm_postgresqlserver - fixed issues with passing parameters while updating existing server instance
4 changes: 3 additions & 1 deletion lib/ansible/modules/cloud/azure/azure_rm_postgresqlserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def exec_module(self, **kwargs):
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":
Expand Down Expand Up @@ -320,6 +320,8 @@ def create_update_postgresqlserver(self):
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.postgresql_client.servers.update(resource_group_name=self.resource_group,
server_name=self.name,
parameters=self.parameters)
Expand Down
1 change: 0 additions & 1 deletion test/integration/targets/azure_rm_postgresqlserver/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ azure_rm_postgresqldatabase
azure_rm_postgresqldatabase_facts
azure_rm_postgresqlfirewallrule
azure_rm_postgresqlfirewallrule_facts
disabled
31 changes: 31 additions & 0 deletions test/integration/targets/azure_rm_postgresqlserver/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,37 @@
- output.changed == false
- output.state == 'Ready'

- name: Update instance of PostgreSQL Server, change storage size
azure_rm_postgresqlserver:
resource_group: "{{ resource_group }}"
name: postgresqlsrv{{ rpfx }}
sku:
name: B_Gen5_1
tier: Basic
location: westus2
storage_mb: 128000
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 postgresql Server
azure_rm_postgresqlserver_facts:
resource_group: "{{ resource_group }}"
name: postgresqlsrv{{ rpfx }}
register: output
- name: Assert that storage size is correct
assert:
that:
- output.servers[0]['storage_mb'] == 128000

- name: Create second instance of PostgreSQL Server
azure_rm_postgresqlserver:
resource_group: "{{ resource_group }}"
Expand Down

0 comments on commit 2f39605

Please sign in to comment.