Our postgresql.conf is from postgresql 9.2 while RHEL8 ships 10.x which leads to postgresql no longer wanting to start (as seen on pagure-stg01). Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
199 lines
5.1 KiB
YAML
199 lines
5.1 KiB
YAML
---
|
|
#
|
|
# Setup postgresql server.
|
|
#
|
|
- name: install postgresql server packages (yum)
|
|
package:
|
|
state: present
|
|
name:
|
|
- postgresql-server
|
|
- postgresql-contrib
|
|
- postgresql-plpython
|
|
- python-psycopg2
|
|
- pxz
|
|
when: ansible_distribution_major_version|int < 8 and ansible_distribution == 'RedHat'
|
|
tags:
|
|
- packages
|
|
- postgresql
|
|
|
|
- name: install postgresql server packages (dnf)
|
|
package:
|
|
state: present
|
|
name:
|
|
- postgresql-server
|
|
- postgresql-contrib
|
|
- postgresql-plpython
|
|
- python-psycopg2
|
|
- pxz
|
|
when: ansible_distribution_major_version|int >= 29 and ansible_distribution == 'Fedora' and ansible_cmdline.ostree is not defined
|
|
tags:
|
|
- packages
|
|
- postgresql
|
|
|
|
- name: install postgresql server packages (dnf)
|
|
package:
|
|
state: present
|
|
name:
|
|
- postgresql-server
|
|
- postgresql-contrib
|
|
- postgresql-plpython3
|
|
- python3-psycopg2
|
|
#- pxz
|
|
when: ansible_distribution_major_version|int >= 8 and ansible_distribution == 'RedHat' and ansible_cmdline.ostree is not defined
|
|
tags:
|
|
- packages
|
|
- postgresql
|
|
|
|
- name: Set kernel shared memory max to a larger value
|
|
sysctl: name=kernel.shmmax value={{ kernel_shmmax }}
|
|
when: kernel_shmmax is defined
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- postgresql
|
|
|
|
- name: Initialize postgres if necessary
|
|
command: /usr/bin/postgresql-setup initdb
|
|
creates=/var/lib/pgsql/data/postgresql.conf
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- postgresql
|
|
|
|
- name: Set postgresql-server to run on boot
|
|
service: name=postgresql enabled=yes
|
|
ignore_errors: true
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- service
|
|
- postgresql
|
|
|
|
- name: Add our postgres config file.
|
|
copy: >
|
|
src={{ item }}
|
|
dest=/var/lib/pgsql/data/{{ item }}
|
|
owner=postgres
|
|
with_items:
|
|
- pg_hba.conf
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- config
|
|
- postgresql
|
|
|
|
- name: postgresql config template
|
|
template: dest=/var/lib/pgsql/data/postgresql.conf src=postgresql.conf
|
|
when: (ansible_distribution_major_version|int < 8 and ansible_distribution == 'RedHat') or ansible_distribution != 'RedHat'
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- config
|
|
- postgresql
|
|
|
|
- name: postgresql recover.conf template (standby only)
|
|
template: dest=/var/lib/pgsql/data/recovery.conf src=recovery.conf
|
|
when: inventory_hostname.startswith('db-koji02')
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- config
|
|
- postgresql
|
|
|
|
- name: Ensure postgres has a place to backup to
|
|
file: dest=/backups state=directory owner=postgres
|
|
when: inventory_hostname.startswith('db-koji02')
|
|
tags:
|
|
- postgresql
|
|
|
|
- name: Copy over backup scriplet
|
|
copy: src=backup-database dest=/usr/local/bin/backup-database mode=0755
|
|
when: not inventory_hostname.startswith('db-koji02')
|
|
tags:
|
|
- postgresql
|
|
|
|
- name: Copy over backup scriplet
|
|
copy: src=backup-database.db-koji02 dest=/usr/local/bin/backup-database mode=0755
|
|
when: inventory_hostname.startswith('db-koji02')
|
|
tags:
|
|
- postgresql
|
|
|
|
- name: Copy over anitya public backup scriplet
|
|
copy: src=backup-database.anitya dest=/usr/local/bin/backup-database.anitya mode=0755
|
|
tags:
|
|
- postgresql
|
|
when: inventory_hostname.startswith('db01.phx2')
|
|
|
|
- name: Copy over anitya publib backup cron
|
|
copy: src=cron-backup-anitya-public dest=/etc/cron.d/cron-backup-anitya-public mode=0644
|
|
tags:
|
|
- postgresql
|
|
when: inventory_hostname.startswith('db01.phx2')
|
|
|
|
- name: Set up some cronjobs to backup databases as configured
|
|
template: >
|
|
src=cron-backup-database
|
|
dest=/etc/cron.d/cron-backup-database-{{ item }}
|
|
with_items:
|
|
- "{{ dbs_to_backup }}"
|
|
when: dbs_to_backup != []
|
|
tags:
|
|
- cron
|
|
- postgresql
|
|
|
|
- name: Set up a cron job to clean long koji sessions on koji database server only
|
|
copy: >
|
|
src=koji-cleanup-sessions.cron
|
|
dest=/etc/cron.d/koji-cleanup-sessions.cron
|
|
when: inventory_hostname.startswith('db-koji01')
|
|
tags:
|
|
- cron
|
|
- postgresql
|
|
|
|
- name: install script to kill long running pgsql jobs
|
|
copy: >
|
|
src=kill_idle_xact_92.sh
|
|
dest=/usr/local/bin/kill_idle_xact_92.sh
|
|
mode=0755
|
|
when: inventory_hostname.startswith('db-koji01')
|
|
tags:
|
|
- cron
|
|
- postgresql
|
|
|
|
- name: Set up a cron job to kill long postresql queries
|
|
copy: >
|
|
src=koji-cleanup-locks.cron
|
|
dest=/etc/cron.d/koji-cleanup-locks.cron
|
|
when: inventory_hostname.startswith('db-koji01')
|
|
tags:
|
|
- cron
|
|
- postgresql
|
|
|
|
- name: Set up a script for cron job to clean long fas sessions on fas database server only
|
|
copy: >
|
|
src=fasdb-cleanup-sessions
|
|
dest=/usr/local/bin/fasdb-cleanup-sessions
|
|
mode=755
|
|
when: inventory_hostname.startswith('db-fas01')
|
|
tags:
|
|
- cron
|
|
- postgresql
|
|
|
|
- name: Set up a cron job to clean long fas sessions on fas database server only
|
|
copy: >
|
|
src=fasdb-cleanup-sessions.cron
|
|
dest=/etc/cron.d/fasdb-cleanup-sessions.cron
|
|
when: inventory_hostname.startswith('db-fas01')
|
|
tags:
|
|
- cron
|
|
- postgresql
|
|
|
|
- name: Set up datanommer/datagrepper SAR script
|
|
copy: >
|
|
src=datagrepper_sar.py
|
|
dest=/usr/local/bin/datagrepper_sar.py mode=0700
|
|
when: inventory_hostname.startswith(('db-datanommer02', 'pgbdr01.stg'))
|
|
tags:
|
|
- postgresql
|
|
- SAR
|
|
- GBDR
|