summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Fenzi <kevin@scrye.com>2016-10-17 19:22:41 +0000
committerKevin Fenzi <kevin@scrye.com>2016-10-17 19:22:41 +0000
commiteb69def46c78cd41b6b657db793d061de965956d (patch)
tree847c834afdca4adb749613eae4924b6bc95194de
parenta5894c93be42ebf2a9724b7ae24163687b819d3d (diff)
downloadansible-eb69def46c78cd41b6b657db793d061de965956d.tar.gz
ansible-eb69def46c78cd41b6b657db793d061de965956d.tar.xz
ansible-eb69def46c78cd41b6b657db793d061de965956d.zip
First stab at autogenerating replication ips for pg_hba
-rw-r--r--inventory/inventory6
-rw-r--r--roles/postgresql_server_bdr/tasks/main.yml2
-rw-r--r--roles/postgresql_server_bdr/templates/pg_hba.conf (renamed from roles/postgresql_server_bdr/files/pg_hba.conf)14
3 files changed, 21 insertions, 1 deletions
diff --git a/inventory/inventory b/inventory/inventory
index 3680b8c9c..ef8669b0b 100644
--- a/inventory/inventory
+++ b/inventory/inventory
@@ -273,6 +273,12 @@ db-qastg01.qa.fedoraproject.org
db-fas01.stg.phx2.fedoraproject.org
db01.stg.phx2.fedoraproject.org
db03.stg.phx2.fedoraproject.org
+
+# postgresql bidirectional replication servers
+[pgbdr]
+
+# postgresql bidirectional replication servers (stg)
+[pgbdr-stg]
db-koji01.stg.phx2.fedoraproject.org
db-koji02.stg.phx2.fedoraproject.org
pgbdr01.stg.phx2.fedoraproject.org
diff --git a/roles/postgresql_server_bdr/tasks/main.yml b/roles/postgresql_server_bdr/tasks/main.yml
index 5a1f32427..ed6ce36f5 100644
--- a/roles/postgresql_server_bdr/tasks/main.yml
+++ b/roles/postgresql_server_bdr/tasks/main.yml
@@ -51,7 +51,7 @@
- postgresql
- name: Add our postgres config file.
- copy: >
+ template: >
src={{ item }}
dest=/var/lib/pgsql/9.4-bdr/data/{{ item }}
owner=postgres
diff --git a/roles/postgresql_server_bdr/files/pg_hba.conf b/roles/postgresql_server_bdr/templates/pg_hba.conf
index 665546f9d..fb5cdfe1e 100644
--- a/roles/postgresql_server_bdr/files/pg_hba.conf
+++ b/roles/postgresql_server_bdr/templates/pg_hba.conf
@@ -76,6 +76,20 @@ host all all 0.0.0.0 0.0.0.0 md5
# Note, I can't think of a reason to make this more restrictive than ipv4 but
# only fakefas needs it so far
host all all ::1/128 md5
+{% for host in groups['pgbdr-stg']|sort %}
+# staging replication hosts
+{% if 'eth0_ip' in hostvars[host] %}# {{ host }}
+host replication all {{ hostvars[host]['eth0_ip'] }} md5
+{% else %}# {{ host }} has no 'eth0_ip' listed
+{% endif %}
+{% endfor %}
+{% for host in groups['pgbdr']|sort %}
+# production replication hosts
+{% if 'eth0_ip' in hostvars[host] %}# {{ host }}
+host replication all {{ hostvars[host]['eth0_ip'] }} md5
+{% else %}# {{ host }} has no 'eth0_ip' listed
+{% endif %}
+{% endfor %}
host all all 10.5.126.188/32 trust
host all all 10.5.126.189/32 trust
host replication all 10.5.126.188/32 trust