File tree 9 files changed +32
-22
lines changed
9 files changed +32
-22
lines changed Original file line number Diff line number Diff line change 1
1
# This is example inventory file!
2
2
# Please specify the ip addresses and connection settings for your environment
3
+ # The specified ip addresses will be used to listen by the cluster components.
3
4
4
5
# "postgresql_exists='true'" if PostgreSQL is already exists and runing
5
6
# "hostname=" variable is optional (used to change the server name)
Original file line number Diff line number Diff line change 138
138
enabled : yes
139
139
state : restarted
140
140
141
- - name : haproxy | wait for port 5000 to become open on the host
141
+ - name : haproxy | check HAProxy is started and accepting connections
142
142
wait_for :
143
- port : 5000
144
- host : 127.0.0.1
143
+ port : 7000
144
+ host : " {{ hostvars[inventory_hostname]['inventory_hostname'] }} "
145
145
state : started
146
146
timeout : 120
147
147
delay : 10
Original file line number Diff line number Diff line change 281
281
- name : Patroni | wait for port 8008 to become open on the host
282
282
wait_for :
283
283
port : 8008
284
- host : " {{ ansible_ssh_host }}"
284
+ host : " {{ hostvars[inventory_hostname]['inventory_hostname'] }}"
285
285
state : started
286
286
timeout : 120
287
287
delay : 10
361
361
- name : Patroni | wait for port 8008 to become open on the host
362
362
wait_for :
363
363
port : 8008
364
- host : " {{ ansible_ssh_host }}"
364
+ host : " {{ hostvars[inventory_hostname]['inventory_hostname'] }}"
365
365
state : started
366
366
timeout : 120
367
367
delay : 10
Original file line number Diff line number Diff line change 76
76
- name : PgBouncer | wait for port "{{ pgbouncer_listen_port }}" to become open on the host
77
77
wait_for :
78
78
port : " {{ pgbouncer_listen_port }}"
79
- host : " {{ ansible_ssh_host }}"
79
+ host : " {{ hostvars[inventory_hostname]['inventory_hostname'] }}"
80
80
state : started
81
81
timeout : 300
82
82
delay : 5
Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ defaults
21
21
22
22
listen stats
23
23
mode http
24
- bind 0.0.0.0 :7000
24
+ bind {{ hostvars[inventory_hostnam e] ['inventory_hostname '] }} :7000
25
25
stats enable
26
26
stats uri /
27
27
28
28
listen master
29
- bind 0.0.0.0 :5000
29
+ bind {{ cluster_vip }} :5000
30
30
maxconn 10000
31
31
option tcplog
32
32
option httpchk OPTIONS /master
@@ -44,7 +44,7 @@ server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['inventory_hos
44
44
{% endif %}
45
45
46
46
listen replicas
47
- bind 0.0.0.0 :5001
47
+ bind {{ cluster_vip }} :5001
48
48
maxconn 10000
49
49
option tcplog
50
50
option httpchk OPTIONS /replica
@@ -63,7 +63,7 @@ server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['inventory_hos
63
63
{% endif %}
64
64
65
65
listen replicas_sync
66
- bind 0.0.0.0 :5002
66
+ bind {{ cluster_vip }} :5002
67
67
maxconn 10000
68
68
option tcplog
69
69
option httpchk OPTIONS /sync
@@ -82,7 +82,7 @@ server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['inventory_hos
82
82
{% endif %}
83
83
84
84
listen replicas_async
85
- bind 0.0.0.0 :5003
85
+ bind {{ cluster_vip }} :5003
86
86
maxconn 10000
87
87
option tcplog
88
88
option httpchk OPTIONS /async
Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ defaults
21
21
22
22
listen stats
23
23
mode http
24
- bind 0.0.0.0 :7000
24
+ bind {{ hostvars[inventory_hostnam e] ['inventory_hostname '] }} :7000
25
25
stats enable
26
26
stats uri /
27
27
28
28
listen master
29
- bind 0.0.0.0 :5000
29
+ bind {{ cluster_vip }} :5000
30
30
maxconn 10000
31
31
option tcplog
32
32
option httpchk OPTIONS /master
@@ -43,7 +43,7 @@ listen master
43
43
44
44
45
45
listen replicas
46
- bind 0.0.0.0 :5001
46
+ bind {{ cluster_vip }} :5001
47
47
maxconn 10000
48
48
option tcplog
49
49
option httpchk OPTIONS /replica
@@ -61,7 +61,7 @@ listen replicas
61
61
62
62
63
63
listen replicas_sync
64
- bind 0.0.0.0 :5002
64
+ bind {{ cluster_vip }} :5002
65
65
maxconn 10000
66
66
option tcplog
67
67
option httpchk OPTIONS /sync
@@ -79,7 +79,7 @@ listen replicas_sync
79
79
80
80
81
81
listen replicas_async
82
- bind 0.0.0.0 :5003
82
+ bind {{ cluster_vip }} :5003
83
83
maxconn 10000
84
84
option tcplog
85
85
option httpchk OPTIONS /async
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ name: {{ ansible_hostname }}
5
5
namespace: /service/
6
6
7
7
restapi:
8
- listen: {{ ansible_ssh_host }}:8008
9
- connect_address: {{ ansible_ssh_host }}:8008
8
+ listen: {{ hostvars[inventory_hostnam e] ['inventory_hostname '] }}:8008
9
+ connect_address: {{ hostvars[inventory_hostnam e] ['inventory_hostname '] }}:8008
10
10
# certfile: /etc/ssl/certs/ssl-cert-snakeoil.pem
11
11
# keyfile: /etc/ssl/private/ssl-cert-snakeoil.key
12
12
# authentication:
@@ -108,8 +108,13 @@ bootstrap:
108
108
109
109
110
110
postgresql:
111
- listen: 0.0.0.0:{{ postgresql_port }}
112
- connect_address: {{ ansible_ssh_host }}:{{ postgresql_port }}
111
+ {% if with_haproxy_load_balancing == "true" or install_pgbouncer == "true" %}
112
+ listen: {{ hostvars[inventory_hostname] ['inventory_hostname'] }},127.0.0.1:{{ postgresql_port }}
113
+ {% endif %}
114
+ {% if with_haproxy_load_balancing != "true" and install_pgbouncer != "true" %}
115
+ listen: {{ hostvars[inventory_hostname] ['inventory_hostname'] }},{{ cluster_vip }},127.0.0.1:{{ postgresql_port }}
116
+ {% endif %}
117
+ connect_address: {{ hostvars[inventory_hostname] ['inventory_hostname'] }}:{{ postgresql_port }}
113
118
use_unix_socket: true
114
119
data_dir: {{ postgresql_data_dir }}
115
120
bin_dir: {{ postgresql_bin_dir }}
Original file line number Diff line number Diff line change 6
6
[pgbouncer]
7
7
logfile = {{ pgbouncer_log_dir }}/pgbouncer.log
8
8
pidfile = /var/run/pgbouncer/pgbouncer.pid
9
- listen_addr = {{ pgbouncer_listen_address | default('*') }}
9
+ {% if with_haproxy_load_balancing == 'true' %}
10
+ listen_addr = {{ hostvars[inventory_hostname] ['inventory_hostname'] }}
11
+ {% endif %}
12
+ {% if with_haproxy_load_balancing != 'true' %}
13
+ listen_addr = {{ hostvars[inventory_hostname] ['inventory_hostname'] }},{{ cluster_vip }}
14
+ {% endif %}
10
15
listen_port = {{ pgbouncer_listen_port | default(6432) }}
11
16
unix_socket_dir = /var/run/postgresql
12
17
auth_type = md5
Original file line number Diff line number Diff line change @@ -144,7 +144,6 @@ postgresql_pg_hba:
144
144
install_pgbouncer : ' true' # or 'false' if you do not want to install and configure the pgbouncer service
145
145
pgbouncer_conf_dir : " /etc/pgbouncer"
146
146
pgbouncer_log_dir : " /var/log/pgbouncer"
147
- pgbouncer_listen_address : ' 0.0.0.0'
148
147
pgbouncer_listen_port : 6432
149
148
max_client_conn : 10000
150
149
max_db_connections : 1000
You can’t perform that action at this time.
0 commit comments