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

106 lines
3 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
- name: Postgres -- Ensuring that the additional directories exist.
file:
name: "{{ item }}"
state: directory
mode: '0700'
owner: postgres
group: postgres
loop:
- "{{ pleroma_postgres_log_dir }}"
- "{{ pleroma_postgres_confd }}"
- name: Postgres -- Ensuring that PostgreSQL is configured.
2019-10-04 00:48:29 +01:00
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
2019-10-04 00:48:29 +01:00
owner: postgres
group: postgres
mode: '0400'
loop:
- { src: etc_postgresql_pg_hba.conf.j2, dest: "{{ pleroma_postgres_base_conf }}/pg_hba.conf" }
- { src: etc_postgresql_confd_postgresql_override.conf, dest: "{{ pleroma_postgres_confd }}/postgresql_override.conf" }
2019-10-02 01:31:38 +01:00
- name: Postgres -- Ensuring that the symlink to the override config is present.
file:
group: postgres
mode: '0700'
owner: postgres
path: "{{ pleroma_postgres_confd_symlink }}"
src: "{{ pleroma_postgres_confd }}"
state: link
- name: Postgres -- Ensuring that the override config is included in the main config.
lineinfile:
group: postgres
line: "include = '{{ pleroma_postgres_confd_symlink }}/postgresql_override.conf'"
mode: '0400'
owner: postgres
path: "{{ pleroma_postgres_base_conf }}/postgresql.conf"
regexp: ^.*include\s=\s'.*'.*$
state: present
- name: Postgres -- Ensuring that PostgreSQL is enabled and started.
2019-10-02 01:31:38 +01:00
service:
name: postgresql
enabled: yes
state: restarted
2019-10-02 01:31:38 +01:00
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.config.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
login_unix_socket: "{{ pleroma_postgres_unix_socket_dir }}"
name: "{{ pleroma.config.db.user }}"
password: "{{ pleroma.config.db.password }}"
2019-10-02 01:31:38 +01:00
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.config.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: "{{ pleroma.config.db.connLimit }}"
2019-10-02 01:31:38 +01:00
encoding: UTF-8
login_unix_socket: "{{ pleroma_postgres_unix_socket_dir }}"
name: "{{ pleroma.config.db.name }}"
owner: "{{ pleroma.config.db.user }}"
2019-10-02 01:31:38 +01:00
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.config.db.name }}"
login_unix_socket: "{{ pleroma_postgres_unix_socket_dir }}"
2019-10-02 01:31:38 +01:00
state: present
loop:
- citext
- pg_trgm
- uuid-ossp
2019-10-04 00:48:29 +01:00
vars:
ansible_ssh_pipelining: true