ansible/roles/postgresql/tasks/main.yml

37 lines
924 B
YAML

#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Set up PostgreSQL
block:
- name: Install PostgreSQL
apt:
name:
- libpq-dev
- postgresql
- postgresql-contrib
- python3-psycopg2
- name: Template out configs
template:
src: postgresql.conf
dest: /etc/postgresql/10/main/postgresql.conf
- name: Start PostgreSQL
systemd:
name: postgresql
enabled: yes
state: started
- name: Configure DB
block:
- name: Create DB user
postgresql_user:
name: "{{ psql_ansible_user }}"
password: "{{ psql_ansible_password }}"
role_attr_flags: SUPERUSER
become: yes
become_user: postgres
- name: Template out backup module
template:
src: backup.sh
dest: /opt/backups/modules/psql.sh
mode: "0600"
become: yes