From 2b187a7e63358bf8ae160c9f9034d65161b4a37f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr>
Date: Mon, 23 Jul 2018 17:47:20 +0200
Subject: [PATCH] add installation of postgresql to ansible

Former-commit-id: 98c2fdffc27eaa33855579fc512db794430d84dc
---
 ansible/deploy.yaml | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/ansible/deploy.yaml b/ansible/deploy.yaml
index 8e357c95..5470b4bd 100644
--- a/ansible/deploy.yaml
+++ b/ansible/deploy.yaml
@@ -48,6 +48,29 @@
         name: "@Development tools"
         state: present
       become: true
+    - name: install PostgreSQL
+      yum:
+        name: "postgresql-server"
+        state: present
+      become: true
+    - name: Initiate database
+      command: service postgresql initdb
+      creates=/var/lib/pgsql/data/postgresql.conf
+    - name: Start PostgreSQL and enable at boot
+      service: name=postgresql
+               enabled=yes
+               state=started
+    - name: Ensure PostgreSQL is listening on all localhost
+      lineinfile: dest=/var/lib/pgsql/data/postgresql.conf
+        regexp='^#?listen_addresses\s*='
+        line="listen_addresses = '127.0.0.1'"
+        state=present
+    - lineinfile: dest=/var/lib/pgsql/data/pg_hba.conf
+                  regexp='host\s+all\s+all\s+127.0.0.1/32\s+md5'
+                  line='host all all 127.0.0.1/32 md5'
+                  insertbefore=BOF
+    - name: restart postgresql service
+      systemd: state=restarted name=postgresql enabled=yes
     #
     # Stop web server(s)
     #
-- 
GitLab