Files
tildes/ansible/roles/postgresql_tildes_dbs/tasks/database.yml
T
Deimos 4cc100ab02 Switch to Debian 10 and Ansible
This changes the site to run on Debian 10 instead of Ubuntu 16.04. It
also fully converts the previous Salt setup to use Ansible instead.

Most of this was a relatively straightforward conversion, and it should
be very close to equivalent. One notable difference is that I removed
the setup for the "monitoring" server, since I wasn't confident that the
way of setting up self-hosted Sentry and Grafana was working any more.
I'll look to re-add that at some point, but it's not urgent.
2021-06-25 00:08:58 -06:00

39 lines
1.1 KiB
YAML

---
- name: Create database and enable access and all necessary extensions
become_user: postgres
block:
- name: Create database
community.postgresql.postgresql_db:
name: "{{ item }}"
owner: tildes
- name: Enable extensions
community.postgresql.postgresql_ext:
name: "{{ extension }}"
db: "{{ item }}"
loop: "{{ extensions }}"
# since the "outer" loop by include_tasks is already using the `item` variable,
# this will use `extension` for the loop inside here
loop_control:
loop_var: extension
- name: Add database to pg_hba.conf
community.postgresql.postgresql_pg_hba:
dest: /etc/postgresql/{{ postgresql_version }}/main/pg_hba.conf
databases: "{{ item }}"
users: tildes
contype: local
method: trust
notify:
- Reload postgresql
- name: Add database to pgbouncer.ini
become_user: root
lineinfile:
path: /etc/pgbouncer/pgbouncer.ini
line: "{{ item }} ="
insertafter: "^\\[databases\\]$"
firstmatch: true
notify:
- Reload pgbouncer