mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Make pg_hba section more compact
This commit is contained in:
@@ -206,9 +206,9 @@ class Postgresql:
|
|||||||
with open(os.path.join(self.data_dir, 'pg_hba.conf'), 'a') as f:
|
with open(os.path.join(self.data_dir, 'pg_hba.conf'), 'a') as f:
|
||||||
f.write('\nhost replication {username} {network} md5\n'.format(**self.replication))
|
f.write('\nhost replication {username} {network} md5\n'.format(**self.replication))
|
||||||
for line in self.config.get('pg_hba', []):
|
for line in self.config.get('pg_hba', []):
|
||||||
if line['type'] == 'hostssl' and self.config['parameters'].get('ssl', 'off').lower() != 'on':
|
if line.split()[0].strip() == 'hostssl' and self.config['parameters'].get('ssl', 'off').lower() != 'on':
|
||||||
continue
|
continue
|
||||||
f.write('{type} {database} {user} {address} {method}\n'. format(**line))
|
f.write(line + '\n')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def primary_conninfo(leader_url):
|
def primary_conninfo(leader_url):
|
||||||
|
|||||||
+2
-10
@@ -13,16 +13,8 @@ postgresql:
|
|||||||
data_dir: data/postgresql0
|
data_dir: data/postgresql0
|
||||||
maximum_lag_on_failover: 1048576 # 1 megabyte in bytes
|
maximum_lag_on_failover: 1048576 # 1 megabyte in bytes
|
||||||
pg_hba:
|
pg_hba:
|
||||||
- type: host
|
- host all all 0.0.0.0/0 md5
|
||||||
database: all
|
- hostssl all all 0.0.0.0/0 md5
|
||||||
user: all
|
|
||||||
address: 0.0.0.0/0
|
|
||||||
method: md5
|
|
||||||
- type: hostssl
|
|
||||||
database: all
|
|
||||||
user: all
|
|
||||||
address: 0.0.0.0/0
|
|
||||||
method: md5
|
|
||||||
replication:
|
replication:
|
||||||
username: replicator
|
username: replicator
|
||||||
password: rep-pass
|
password: rep-pass
|
||||||
|
|||||||
+2
-10
@@ -13,16 +13,8 @@ postgresql:
|
|||||||
data_dir: data/postgresql1
|
data_dir: data/postgresql1
|
||||||
maximum_lag_on_failover: 1048576 # 1 megabyte in bytes
|
maximum_lag_on_failover: 1048576 # 1 megabyte in bytes
|
||||||
pg_hba:
|
pg_hba:
|
||||||
- type: host
|
- host all all 0.0.0.0/0 md5
|
||||||
database: all
|
- hostssl all all 0.0.0.0/0 md5
|
||||||
user: all
|
|
||||||
address: 0.0.0.0/0
|
|
||||||
method: md5
|
|
||||||
- type: hostssl
|
|
||||||
database: all
|
|
||||||
user: all
|
|
||||||
address: 0.0.0.0/0
|
|
||||||
method: md5
|
|
||||||
replication:
|
replication:
|
||||||
username: replicator
|
username: replicator
|
||||||
password: rep-pass
|
password: rep-pass
|
||||||
|
|||||||
@@ -93,9 +93,7 @@ class TestPostgresql(unittest.TestCase):
|
|||||||
subprocess.call = subprocess_call
|
subprocess.call = subprocess_call
|
||||||
self.p = Postgresql({'name': 'test0', 'data_dir': 'data/test0', 'listen': '127.0.0.1, *:5432',
|
self.p = Postgresql({'name': 'test0', 'data_dir': 'data/test0', 'listen': '127.0.0.1, *:5432',
|
||||||
'connect_address': '127.0.0.2:5432',
|
'connect_address': '127.0.0.2:5432',
|
||||||
'pg_hba': [{'type': 'hostssl', 'database': 'all', 'user': 'all', 'address': '0.0.0.0/0',
|
'pg_hba': ['hostssl all all 0.0.0.0/0 md5', 'host all all 0.0.0.0/0 md5'],
|
||||||
'method': 'md5'}, {'type': 'host', 'database': 'all', 'user': 'all',
|
|
||||||
'address': '0.0.0.0/0', 'method': 'md5'}],
|
|
||||||
'replication': {'username': 'replicator',
|
'replication': {'username': 'replicator',
|
||||||
'password': 'rep-pass',
|
'password': 'rep-pass',
|
||||||
'network': '127.0.0.1/32'},
|
'network': '127.0.0.1/32'},
|
||||||
|
|||||||
Reference in New Issue
Block a user