- name: Install postgresql
yum:
name: "{{ item }}"
state: present
become: true
with_items:
- postgresql-server
- postgresql-pgpool-II
- name: Initialize postgresql
command: postgresql-setup initdb
# Will error when database has already been initialized so just ignore it
ignore_errors: yes
- name: Install adapter for python
name: python-psycopg2
- name: Configure pgpool
template:
src: pgpool.conf.j2
dest: /etc/pgpool-II/pgpool.conf
- name: Create oiddir for pgpool
file:
path: "{{ memqcache_oiddir }}"
state: directory
- name: Start postgresql, pgpool and enable at boot
systemd:
enabled: yes
state: started
- postgresql
- pgpool
- name: Create nyaapantsu database
postgresql_db:
name: "{{ nyaapantsu_dbname }}"
become_user: postgres
# TODO Probably better idea to not set SUPERUSER
- name: Create nyaapantsu user
postgresql_user:
db: "{{ nyaapantsu_dbname }}"
name: "{{ nyaapantsu_user }}"
password: "{{ nyaapantsu_password }}"
role_attr_flags: SUPERUSER,LOGIN
- name: Grant privileges to user
postgresql_privs:
priv: ALL
roles: "{{ nyaapantsu_user }}"
type: database
- name: Add custom pg_hba.conf
src: pg_hba.conf.j2
dest: /var/lib/pgsql/data/pg_hba.conf
- name: Add .pgpass
src: pgpass.j2
dest: ~/.pgpass
mode: 0600
- name: Reload postgres
name: postgresql
state: reloaded