postgresql_pg_hba: fix a crash when a new rule with an 'options' field replaces a rule without or vice versa (#72290)

pull/72336/head
Andrew Klychkov 5 years ago committed by GitHub
parent 2beeeb8a27
commit e7b2ba4ef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- postgresql_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/issues/1108).

@ -342,7 +342,7 @@ class PgHba(object):
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

@ -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"

Loading…
Cancel
Save