-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks_postgres.yml
37 lines (32 loc) · 1.27 KB
/
tasks_postgres.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
- name: Add PostgreSQL repository
yum:
name: https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
- name: Install PostgreSQL
yum:
name: postgresql95-server,postgresql95-libs,postgresql95-contrib
- name: Setup PostgreSQL
command: /usr/pgsql-9.5/bin/initdb --encoding=UTF8 --locale=C --auth-host=md5 --auth-local=peer -D /var/lib/pgsql/9.5/data
args:
creates: /var/lib/pgsql/9.5/data/postgresql.conf
become: yes
become_user: postgres
- name: Configure PostgreSQL
replace:
dest: /var/lib/pgsql/9.5/data/postgresql.conf
regexp: '{{ item.regexp }}'
replace: '{{ item.line }}'
with_items:
- { regexp: '^#?shared_buffers.*', line: 'shared_buffers = 512MB' }
- { regexp: '^#?synchronous_commit.*', line: 'synchronous_commit = off' }
- { regexp: '^#?checkpoint_segments.*', line: 'checkpoint_segments = 32' }
- { regexp: '^#?checkpoint_completion_target.*', line: 'checkpoint_completion_target = 0.9' }
- name: Enable PostgreSQL service
service:
name: postgresql-9.5
enabled: yes
state: started
- name: Set PostgreSQL password
command: psql -U postgres -c "ALTER USER postgres WITH PASSWORD '{{ pg_pwd }}';"
become: yes
become_user: postgres