2020-07-28 08:38:21 -05:00
|
|
|
#!/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
|
2020-07-28 08:38:21 -05:00
|
|
|
- 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
|
2020-08-01 17:53:50 -05:00
|
|
|
notify: restart psql
|
2020-07-28 08:38:21 -05:00
|
|
|
- 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"
|
2020-07-28 08:38:21 -05:00
|
|
|
become: yes
|