70 lines
1.5 KiB
YAML
70 lines
1.5 KiB
YAML
---
|
|
#
|
|
# Setup postgresql server.
|
|
#
|
|
- name: install postgresql server packages
|
|
yum: name={{ item }} state=installed
|
|
with_items:
|
|
- postgresql-server
|
|
- postgresql-contrib
|
|
- postgresql-plpython
|
|
- python-psycopg2
|
|
tags:
|
|
- packages
|
|
- postgresql
|
|
|
|
- name: Set kernel shared memory max to a larger value
|
|
sysctl: name=kernel.shmmax value=68719476736
|
|
notify:
|
|
- restart postgresql
|
|
|
|
- name: Initialize postgres if necessary
|
|
command: /usr/bin/postgresql-setup initdb creates=/var/lib/pgsql/data
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- postgresql
|
|
|
|
- name: Set postgresql-server to run on boot
|
|
service: name=postgresql enabled=yes
|
|
ignore_errors: true
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- service
|
|
- postgresql
|
|
|
|
- name: Add our postgres config file.
|
|
copy: >
|
|
src={{ item }}
|
|
dest=/var/lib/pgsql/data/{{ item }}
|
|
owner=postgres
|
|
with_items:
|
|
- pg_hba.conf
|
|
- postgresql.conf
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- config
|
|
- postgresql
|
|
|
|
- name: Ensure postgres has a place to backup to
|
|
file: dest=/backups state=directory owner=postgres
|
|
tags:
|
|
- postgresql
|
|
|
|
- name: Copy over backup scriplet
|
|
copy: src=backup-database dest=/usr/local/bin/backup-database mode=0755
|
|
tags:
|
|
- postgresql
|
|
|
|
- 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
|
|
- postgresql
|