45 lines
1.1 KiB
YAML
45 lines
1.1 KiB
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: "{{ 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
|
|
- name: Configure DB
|
|
block:
|
|
- name: Create DB user
|
|
postgresql_user:
|
|
name: "{{ psql.ansible.user }}"
|
|
password: "{{ psql.ansible.pass }}"
|
|
role_attr_flags: SUPERUSER
|
|
- name: Create maintenance DB
|
|
postgresql_db:
|
|
name: "{{ psql.ansible.user }}"
|
|
owner: "{{ psql.ansible.user }}"
|
|
become: yes
|
|
become_user: postgres
|
|
- name: Template out backup module
|
|
template:
|
|
src: backup.sh
|
|
dest: /opt/backups/modules/psql.sh
|
|
mode: "0600"
|
|
become: yes
|