Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update postgresql_pg_hba.py #1124

Merged
merged 3 commits into from
Oct 21, 2020
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/1124-pg_hba-dictkey bugfix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- pg_hba - fix a crash when a new rule with an 'options' field replaces a rule without or vice versa (https://github.com/ansible-collections/community.general/pull/1124).
2 changes: 1 addition & 1 deletion plugins/modules/database/postgresql/postgresql_pg_hba.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def add_rule(self, rule):
ekeys = set(list(oldrule.keys()) + list(rule.keys()))
ekeys.remove('line')
for k in ekeys:
if oldrule[k] != rule[k]:
if oldrule.get(k) != rule.get(k):
raise PgHbaRuleChanged('{0} changes {1}'.format(rule, oldrule))
except PgHbaRuleChanged:
self.rules[key] = rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@
register: pg_hba_change
with_items: "{{pg_hba_test_ips}}"

- name: Able to add options on rule without
postgresql_pg_hba:
dest: "/tmp/pg_hba.conf"
users: "+some"
order: "sud"
state: "present"
contype: "local"
method: "cert"
options: "{{ item }}"
address: ""
with_items:
- ""
- "clientcert=1"

- name: Retain options even if they contain spaces
postgresql_pg_hba:
dest: "/tmp/pg_hba.conf"
Expand Down