Dan Anglin
b03c997960
This merge request changes the project from a single role project to a single playbook project with multiple plays and roles. The single playbook has multiple plays with each having its own role to install and configure the different components to run Pleroma. (postgres database, pleroma backend and nginx). Certain playbooks can be executed by specifying the relevant tags. This change is the first of many changes to start supporting installations on both single and multiple hosts. This change includes also includes: - inventory file. - host_vars directory for users to add their variables. - an init playbook to merge the default and the user defined config for Pleroma. - users can now specify whether to validate certs when performing acme challenges (default: true). - more task templating.
105 lines
3 KiB
YAML
105 lines
3 KiB
YAML
---
|
|
- name: Postgres -- Ensure that PostgreSQL is installed.
|
|
apk:
|
|
name: "{{ pleroma_postgres_packages }}"
|
|
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.
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
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" }
|
|
|
|
- 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.
|
|
service:
|
|
name: postgresql
|
|
enabled: yes
|
|
state: restarted
|
|
|
|
- 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.config.db.user }} exists.
|
|
become_user: postgres
|
|
postgresql_user:
|
|
db: postgres
|
|
encrypted: yes
|
|
login_unix_socket: "{{ pleroma_postgres_unix_socket_dir }}"
|
|
name: "{{ pleroma.config.db.user }}"
|
|
password: "{{ pleroma.config.db.password }}"
|
|
state: present
|
|
vars:
|
|
ansible_ssh_pipelining: true
|
|
|
|
- name: Postgres -- Ensuring that the database {{ pleroma.config.db.name }} exists.
|
|
become_user: postgres
|
|
postgresql_db:
|
|
conn_limit: "{{ pleroma.config.db.connLimit }}"
|
|
encoding: UTF-8
|
|
login_unix_socket: "{{ pleroma_postgres_unix_socket_dir }}"
|
|
name: "{{ pleroma.config.db.name }}"
|
|
owner: "{{ pleroma.config.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.config.db.name }}"
|
|
login_unix_socket: "{{ pleroma_postgres_unix_socket_dir }}"
|
|
state: present
|
|
loop:
|
|
- citext
|
|
- pg_trgm
|
|
- uuid-ossp
|
|
vars:
|
|
ansible_ssh_pipelining: true
|