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

76 lines
1.9 KiB
YAML
Raw Normal View History

2019-10-02 01:31:38 +01:00
---
- 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
2019-10-04 00:48:29 +01:00
# -----------------------------------
# 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
2019-10-02 01:31:38 +01:00
2019-10-04 00:48:29 +01:00
- name: Postgres -- Ensure that PostgreSQL is enabled and started.
2019-10-02 01:31:38 +01:00
service:
name: postgresql
enabled: yes
state: started
2019-10-04 00:48:29 +01:00
- name: Postgres -- Ensuring that Postgres is available before continuing.
2019-10-02 01:31:38 +01:00
wait_for:
connect_timeout: 10
delay: 5
host: localhost
port: 5432
state: started
- name: Postgres -- Ensuring that the database user {{ pleroma_db_user }} exists.
2019-10-04 00:48:29 +01:00
become_user: postgres
2019-10-02 01:31:38 +01:00
postgresql_user:
db: postgres
encrypted: yes
name: "{{ pleroma_db_user }}"
password: "{{ pleroma_db_password }}"
state: present
2019-10-04 00:48:29 +01:00
vars:
ansible_ssh_pipelining: true
2019-10-02 01:31:38 +01:00
- name: Postgres -- Ensuring that the database {{ pleroma_db_name }} exists.
2019-10-04 00:48:29 +01:00
become_user: postgres
2019-10-02 01:31:38 +01:00
postgresql_db:
conn_limit: "20"
encoding: UTF-8
name: "{{ pleroma_db_name }}"
owner: "{{ pleroma_db_user }}"
state: present
2019-10-04 00:48:29 +01:00
vars:
ansible_ssh_pipelining: true
2019-10-02 01:31:38 +01:00
- name: Postgres -- Ensuring the PostgreSQL extensions is added to the database.
2019-10-04 00:48:29 +01:00
become_user: postgres
2019-10-02 01:31:38 +01:00
postgresql_ext:
name: "{{ item }}"
db: "{{ pleroma_db_name }}"
state: present
loop:
- citext
- pg_trgm
- uuid-ossp
2019-10-04 00:48:29 +01:00
vars:
ansible_ssh_pipelining: true