This repository has been archived on 2023-05-06. You can view files and clone it, but cannot push or open issues or pull requests.
pleroma-ansible-playbook/tasks/postgres.yml

75 lines
1.9 KiB
YAML

---
- name: Postgres -- Ensure that PostgreSQL is installed.
apk:
name: postgresql, postgresql-contrib, py-psycopg2
state: present
- name: Postgres -- Ensure that the database is initialised.
command:
argv:
- /etc/init.d/postgresql
- setup
creates: /var/lib/postgresql/11/data/postgresql.conf
# -----------------------------------
# TODO: Take a look at the postgres
# configuration file before going
# into production.
# -----------------------------------
- name: Postgres -- Ensure that pg_hba.conf is configured.
template:
src: etc_postgresql_pg_hba.conf.j2
dest: /etc/postgresql/pg_hba.conf
owner: postgres
group: postgres
mode: '0400'
notify: restart postgres
- name: Postgres -- Ensure that PostgreSQL is enabled and started.
service:
name: postgresql
enabled: yes
state: started
- name: Postgres -- Ensuring that Postgres is available before continuing.
wait_for:
connect_timeout: 10
delay: 5
host: localhost
port: 5432
state: started
- name: Postgres -- Ensuring that the database user {{ pleroma_db_user }} exists.
become_user: postgres
postgresql_user:
db: postgres
encrypted: yes
name: "{{ pleroma_db_user }}"
password: "{{ pleroma_db_password }}"
state: present
vars:
ansible_ssh_pipelining: true
- name: Postgres -- Ensuring that the database {{ pleroma_db_name }} exists.
become_user: postgres
postgresql_db:
conn_limit: "20"
encoding: UTF-8
name: "{{ pleroma_db_name }}"
owner: "{{ pleroma_db_user }}"
state: present
vars:
ansible_ssh_pipelining: true
- name: Postgres -- Ensuring the PostgreSQL extensions is added to the database.
become_user: postgres
postgresql_ext:
name: "{{ item }}"
db: "{{ pleroma_db_name }}"
state: present
loop:
- citext
- pg_trgm
- uuid-ossp
vars:
ansible_ssh_pipelining: true