Browse Source

Add postgres role

Colin Powell 4 năm trước cách đây
mục cha
commit
7ec9f77529

+ 8 - 0
ansible/roles/postgres/files/pg_hba.conf.patch

@@ -0,0 +1,8 @@
+@@ -91,3 +91,7 @@
+local   replication     all                                     trust
+host    replication     all             127.0.0.1/32            trust
+host    replication     all             ::1/128                 trust
++
++# All IPv4 and IPv6 connections allowed and trusted (don't run this on an IP oustide the local net
++host    all             all             0.0.0.0/0               trust
++host    all             all             ::0/0                   trust

+ 9 - 0
ansible/roles/postgres/files/postgresql.conf.patch

@@ -0,0 +1,9 @@
+@@ -56,7 +56,7 @@
+
+ # - Connection Settings -
+
+-#listen_addresses = '127.0.0.1'		# what IP address(es) to listen on;
++listen_addresses = '*'			# what IP address(es) to listen on;
+ 					# comma-separated list of addresses;
+ 					# defaults to 'localhost'; use '*' for all
+ 					# (change requires restart)

+ 5 - 0
ansible/roles/postgres/handlers/main.yml

@@ -0,0 +1,5 @@
+---
+- name: PostgreSQL restarted
+  service:
+    name: postgresql
+    state: restarted

+ 23 - 0
ansible/roles/postgres/tasks/main.yml

@@ -0,0 +1,23 @@
+---
+- name: Package cache updated
+  shell: pkg update -f
+
+- name: PostgreSQL packages installed
+  pkgng:
+    name: "postgresql12-server postgresql12-client"
+    state: present
+
+- name: PostgreSQL enabled
+  shell: sysrc postgresql_enable="YES"
+
+- name: PostgreSQL access file patched
+  patch:
+    src: pg_hba.conf.conf.patch
+    dest: /var/db/postgres/data12/pg_hba.conf
+  notify: PostgreSQL restarted
+
+- name: PostgreSQL config file patched
+  patch:
+    src: postgresql.conf.patch
+    dest: /var/db/postgres/data12/postgresql.conf
+  notify: PostgreSQL restarted