summaryrefslogtreecommitdiffstats
path: root/roles/postgresql_server/tasks/main.yml
blob: 7e91a6ba2775be6d023ad953978bbfb558d3b065 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
---
#
# 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

- name: Set postgresql-server to run on boot
  service: name=postgresql enabled=yes
  ignore_errors: true
  notify:
  - restart postgresql
  tags:
  - service

- 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

- name: Ensure postgres has a place to backup to
  file: dest=/backups state=directory owner=postgres

- name: Copy over backup scriplet
  copy: src=backup-database dest=/usr/local/bin/backup-database mode=0755

- 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