This repository has been archived by the owner on Aug 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from python/pgpool
Implement a pgpool-II/keepalived pair to sit in front of the PostgreSQL cluster.
- Loading branch information
Showing
17 changed files
with
455 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
file_client: local | ||
file_roots: | ||
base: | ||
- /srv/salt | ||
grains: | ||
roles: | ||
- develop | ||
- postgresql_pgpool | ||
- primary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
file_client: local | ||
file_roots: | ||
base: | ||
- /srv/salt | ||
grains: | ||
roles: | ||
- develop | ||
- postgresql_pgpool |
10 changes: 6 additions & 4 deletions
10
...ing/salt/roots/pillar/postgresql/init.sls → .../salt/roots/pillar/postgresql/cluster.sls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
|
||
firewall: | ||
ports: | ||
- 5432 | ||
|
||
postgresql_cluster: | ||
primary_server: 172.16.57.5 | ||
standby_servers: | ||
- 172.16.57.6 | ||
|
||
pgpool_cluster: | ||
nodes: | ||
- 172.16.57.7 | ||
- 172.16.57.8 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
pgpool_cluster: | ||
nodes: | ||
- 172.16.57.7 | ||
- 172.16.57.8 | ||
virtual_ip: | ||
172.16.57.100 | ||
|
||
virtual_ips: | ||
172.16.57.100: | ||
auth_pass: sosecret | ||
vrid: 51 | ||
cidr: 172.16.57.0/24 | ||
|
||
firewall: | ||
ports: | ||
- 9000 | ||
- 9694 | ||
- 9898 | ||
- 9999 | ||
- 5432 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
firewall: | ||
ports: | ||
- 5432 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
provisioning/salt/roots/salt/keepalived/config/keepalived.conf.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% for vip, config in salt['pillar.get']('virtual_ips').iteritems() %} | ||
{% set auth_pass = config.get('auth_pass', 'pass') %} | ||
{% set vrid = config.get('vrid', '50') %} | ||
{% set interface = salt['ip_picker.interfaces_for_cidr'](cidr=config['cidr'])[0] %} | ||
|
||
vrrp_instance VI_{{ loop.index }} { | ||
interface {{ interface }} | ||
virtual_router_id {{ vrid }} | ||
{% if 'primary' in salt['grains.get']('roles') %} | ||
state MASTER | ||
priority 150 | ||
{% else %} | ||
state BACKUP | ||
priority 100 | ||
{% endif %} | ||
advert_int 1 | ||
authentication { | ||
auth_type PASS | ||
auth_pass {{ auth_pass }} | ||
} | ||
virtual_ipaddress { | ||
{{ vip }} | ||
} | ||
} | ||
|
||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
net.ipv4.ip_forward: | ||
sysctl.present: | ||
- value: 1 | ||
|
||
/etc/keepalived/keepalived.conf: | ||
file.managed: | ||
- source: salt://keepalived/config/keepalived.conf.jinja | ||
- template: jinja | ||
- user: root | ||
- group: root | ||
- mode: 640 | ||
|
||
keepalived: | ||
pkg: | ||
- installed | ||
service: | ||
- running | ||
- enable: True | ||
- reload: True | ||
- watch: | ||
- file: /etc/keepalived/keepalived.conf | ||
- require: | ||
- file: /etc/keepalived/keepalived.conf | ||
- sysctl: net.ipv4.ip_forward |
1 change: 1 addition & 0 deletions
1
provisioning/salt/roots/salt/postgresql/cluster/config/pcp.conf.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
postgres:e8a48653851e28c69d0506508fb27fc5 |
4 changes: 4 additions & 0 deletions
4
provisioning/salt/roots/salt/postgresql/cluster/config/pg_hba.conf.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
#TYPE DATABASE USER ADDRESS METHOD | ||
{% set config = salt['pillar.get']('postgresql_cluster', {}) %} | ||
{% set pgpool_config = salt['pillar.get']('pgpool_cluster', {}) %} | ||
local all all ident | ||
host all all 127.0.0.1/32 md5 | ||
host all all ::1/128 md5 | ||
host replication postgres {{ config.get('primary_server') }}/32 trust | ||
{% for server in config.get('standby_servers') %} | ||
host replication postgres {{ server }}/32 trust | ||
{% endfor %} | ||
{% for server in pgpool_config.get('nodes') %} | ||
host all postgres {{ server }}/32 trust | ||
{% endfor %} |
Oops, something went wrong.