2013-06-24 21:27:04 +00:00
|
|
|
---
|
|
|
|
#
|
|
|
|
# Setup postgresql server.
|
|
|
|
#
|
|
|
|
- name: install postgresql server packages
|
2014-01-01 19:15:11 +00:00
|
|
|
yum: name={{ item }} state=installed
|
2013-06-24 21:27:04 +00:00
|
|
|
with_items:
|
|
|
|
- postgresql-server
|
|
|
|
- postgresql-contrib
|
|
|
|
- postgresql-plpython
|
2013-09-12 22:27:42 +00:00
|
|
|
- python-psycopg2
|
2013-06-24 21:27:04 +00:00
|
|
|
tags:
|
|
|
|
- packages
|
2014-09-25 20:26:49 +00:00
|
|
|
- postgresql
|
2013-06-24 21:27:04 +00:00
|
|
|
|
2014-09-25 20:42:43 +00:00
|
|
|
- name: Set kernel shared memory max to a larger value
|
|
|
|
sysctl: name=kernel.shmmax value=68719476736
|
|
|
|
notify:
|
|
|
|
- restart postgresql
|
|
|
|
|
2014-09-25 20:30:31 +00:00
|
|
|
- name: Initialize postgres if necessary
|
|
|
|
command: /usr/bin/postgresql-setup initdb creates=/var/lib/pgsql/data
|
|
|
|
notify:
|
|
|
|
- restart postgresql
|
|
|
|
tags:
|
|
|
|
- postgresql
|
|
|
|
|
2013-06-26 20:14:32 +00:00
|
|
|
- name: Set postgresql-server to run on boot
|
|
|
|
service: name=postgresql enabled=yes
|
|
|
|
ignore_errors: true
|
|
|
|
notify:
|
|
|
|
- restart postgresql
|
|
|
|
tags:
|
|
|
|
- service
|
2014-09-25 20:26:49 +00:00
|
|
|
- postgresql
|
2014-01-10 20:40:08 +00:00
|
|
|
|
|
|
|
- name: Add our postgres config file.
|
|
|
|
copy: >
|
2014-01-10 20:52:18 +00:00
|
|
|
src={{ item }}
|
|
|
|
dest=/var/lib/pgsql/data/{{ item }}
|
2014-01-10 20:40:08 +00:00
|
|
|
owner=postgres
|
2014-01-10 20:52:18 +00:00
|
|
|
with_items:
|
|
|
|
- pg_hba.conf
|
|
|
|
- postgresql.conf
|
2014-01-10 20:40:08 +00:00
|
|
|
notify:
|
|
|
|
- restart postgresql
|
|
|
|
tags:
|
|
|
|
- config
|
2014-09-25 20:26:49 +00:00
|
|
|
- postgresql
|
2014-01-10 21:29:20 +00:00
|
|
|
|
|
|
|
- name: Ensure postgres has a place to backup to
|
|
|
|
file: dest=/backups state=directory owner=postgres
|
2014-09-25 20:26:49 +00:00
|
|
|
tags:
|
|
|
|
- postgresql
|
2014-01-10 21:29:20 +00:00
|
|
|
|
2014-01-13 16:16:18 +00:00
|
|
|
- name: Copy over backup scriplet
|
|
|
|
copy: src=backup-database dest=/usr/local/bin/backup-database mode=0755
|
2014-09-25 20:26:49 +00:00
|
|
|
tags:
|
|
|
|
- postgresql
|
2014-01-13 16:16:18 +00:00
|
|
|
|
2014-01-10 21:29:20 +00:00
|
|
|
- name: Set up some cronjobs to backup databases as configured
|
|
|
|
template: >
|
|
|
|
src=cron-backup-database
|
|
|
|
dest=/etc/cron.d/cron-backup-database-{{ item }}
|
|
|
|
with_items:
|
|
|
|
- "{{ dbs_to_backup }}"
|
|
|
|
when: dbs_to_backup != []
|
|
|
|
tags:
|
|
|
|
- cron
|
2014-09-25 20:26:49 +00:00
|
|
|
- postgresql
|