ansible/roles/postgresql/tasks/main.yml

45 lines
1.1 KiB
YAML
Raw Normal View History

#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Set up PostgreSQL
block:
- name: Install PostgreSQL
apt:
name:
- libpq-dev
2020-07-28 08:46:45 -05:00
- postgresql
- postgresql-contrib
- python3-psycopg2
2020-08-01 17:51:44 -05:00
- name: Template out configs
template:
src: "{{ item }}"
dest: "/etc/postgresql/10/main/{{ item }}"
loop:
- postgresql.conf
- pg_hba.conf
notify: restart psql
- name: Start PostgreSQL
systemd:
name: postgresql
enabled: yes
state: started
2020-08-01 17:51:44 -05:00
- name: Configure DB
block:
- name: Create DB user
postgresql_user:
2020-08-02 19:36:46 -05:00
name: "{{ psql.ansible.user }}"
password: "{{ psql.ansible.pass }}"
2020-08-01 17:51:44 -05:00
role_attr_flags: SUPERUSER
- name: Create maintenance DB
postgresql_db:
2020-08-02 19:36:46 -05:00
name: "{{ psql.ansible.user }}"
owner: "{{ psql.ansible.user }}"
2020-08-01 17:51:44 -05:00
become: yes
become_user: postgres
2020-08-01 16:44:04 -05:00
- name: Template out backup module
template:
src: backup.sh
2020-08-01 17:00:25 -05:00
dest: /opt/backups/modules/psql.sh
2020-08-01 16:44:04 -05:00
mode: "0600"
become: yes