--- - 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.config.db.user }} exists. become_user: postgres postgresql_user: db: postgres encrypted: yes 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: "20" encoding: UTF-8 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 }}" state: present loop: - citext - pg_trgm - uuid-ossp vars: ansible_ssh_pipelining: true