mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Update postgresql_pg_hba.py
Fixes #1108
* Create changelog fragment for pull 1124
* Adding a unit test for pg_hba
(cherry picked from commit 3a5669991f
)
Co-authored-by: Sebastiaan Mannem <sebastiaan.mannem@enterprisedb.com>
This commit is contained in:
parent
b035084caa
commit
d0a9ced474
3 changed files with 17 additions and 1 deletions
2
changelogs/fragments/1124-pg_hba-dictkey bugfix.yaml
Normal file
2
changelogs/fragments/1124-pg_hba-dictkey bugfix.yaml
Normal file
|
@ -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).
|
|
@ -335,7 +335,7 @@ class PgHba(object):
|
||||||
ekeys = set(list(oldrule.keys()) + list(rule.keys()))
|
ekeys = set(list(oldrule.keys()) + list(rule.keys()))
|
||||||
ekeys.remove('line')
|
ekeys.remove('line')
|
||||||
for k in ekeys:
|
for k in ekeys:
|
||||||
if oldrule[k] != rule[k]:
|
if oldrule.get(k) != rule.get(k):
|
||||||
raise PgHbaRuleChanged('{0} changes {1}'.format(rule, oldrule))
|
raise PgHbaRuleChanged('{0} changes {1}'.format(rule, oldrule))
|
||||||
except PgHbaRuleChanged:
|
except PgHbaRuleChanged:
|
||||||
self.rules[key] = rule
|
self.rules[key] = rule
|
||||||
|
|
|
@ -58,6 +58,20 @@
|
||||||
register: pg_hba_change
|
register: pg_hba_change
|
||||||
with_items: "{{pg_hba_test_ips}}"
|
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
|
- name: Retain options even if they contain spaces
|
||||||
postgresql_pg_hba:
|
postgresql_pg_hba:
|
||||||
dest: "/tmp/pg_hba.conf"
|
dest: "/tmp/pg_hba.conf"
|
||||||
|
|
Loading…
Reference in a new issue