ansible/roles/postgresql/tasks/main.yml

37 lines
924 B
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: postgresql.conf
dest: /etc/postgresql/10/main/postgresql.conf
- 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:
name: "{{ psql_ansible_user }}"
password: "{{ psql_ansible_password }}"
role_attr_flags: SUPERUSER
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