Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/20241109-azure_manage_postgresql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Fixed the undefined variables issue in the create.yml and delete.yml of azure_manage_postgresql role.
3 changes: 3 additions & 0 deletions roles/azure_manage_postgresql/tasks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
value: "{{ item.value }}"
with_items: "{{ azure_manage_postgresql_postgresql_settings }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't we still have an error here if azure_manage_postgresql_postgresql_settings is not defined?

I think a better solution would be to set this in defaults/main.yml

azure_manage_postgresql_postgresql_settings: []

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in case of undefined var it won't even come to this line, will fail on "when". But I'll set in defaults/main.yml , thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to remove the default() calls now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, sorry. I thought I already pushed it, my fault..

when:
- azure_manage_postgresql_postgresql_settings is defined
- azure_manage_postgresql_postgresql_settings | length > 0

- name: Update PostgreSQL Server Firewall rules
Expand All @@ -75,6 +76,7 @@
end_ip_address: "{{ item.end_ip_address }}"
with_items: "{{ azure_manage_postgresql_postgresql_firewall_rules }}"
when:
- azure_manage_postgresql_postgresql_firewall_rules is defined
- azure_manage_postgresql_postgresql_firewall_rules | length > 0

- name: Create/Update PostgreSQL Database instances
Expand All @@ -87,4 +89,5 @@
force_update: "{{ item.force | default(omit) }}"
with_items: "{{ azure_manage_postgresql_postgresql_database_instances }}"
when:
- azure_manage_postgresql_postgresql_database_instances is defined
- azure_manage_postgresql_postgresql_database_instances | length > 0
9 changes: 9 additions & 0 deletions roles/azure_manage_postgresql/tasks/delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
value: "{{ item.value }}"
state: absent
with_items: "{{ azure_manage_postgresql_postgresql_settings }}"
when:
- azure_manage_postgresql_postgresql_settings is defined
- azure_manage_postgresql_postgresql_settings | length > 0

- name: Delete PostgreSQL Server Firewall rules
azure.azcollection.azure_rm_postgresqlfirewallrule:
Expand All @@ -15,6 +18,9 @@
name: "{{ item.name }}"
state: absent
with_items: "{{ azure_manage_postgresql_postgresql_firewall_rules }}"
when:
- azure_manage_postgresql_postgresql_firewall_rules is defined
- azure_manage_postgresql_postgresql_firewall_rules | length > 0

- name: Delete PostgreSQL Database instances
azure.azcollection.azure_rm_postgresqldatabase:
Expand All @@ -24,6 +30,9 @@
force_update: "{{ item.force | default(omit) }}"
state: absent
with_items: "{{ azure_manage_postgresql_postgresql_database_instances }}"
when:
- azure_manage_postgresql_postgresql_database_instances is defined
- azure_manage_postgresql_postgresql_database_instances | length > 0

- name: Delete PostgreSQL Server if requested
azure.azcollection.azure_rm_postgresqlserver:
Expand Down