2013-06-24 21:27:04 +00:00
|
|
|
---
|
|
|
|
#
|
2016-08-08 19:36:31 +00:00
|
|
|
# Setup postgresql server.
|
2013-06-24 21:27:04 +00:00
|
|
|
#
|
2022-06-07 15:40:56 -07:00
|
|
|
- name: on rhel8 hosts enable the postgresql 12 module.
|
|
|
|
copy:
|
|
|
|
dest: /etc/dnf/modules.d/postgresql.module
|
|
|
|
content: |
|
|
|
|
[postgresql]
|
|
|
|
name=postgresql
|
|
|
|
stream=12
|
|
|
|
profiles=
|
|
|
|
state=enabled
|
|
|
|
when: ansible_distribution_major_version|int >= 8 and ansible_distribution == 'RedHat' and not inventory_hostname.startswith('db-fas01.stg')
|
|
|
|
|
|
|
|
- name: on db-fas01.stg enable the postgresql 9.6 module.
|
|
|
|
copy:
|
|
|
|
dest: /etc/dnf/modules.d/postgresql.module
|
|
|
|
content: |
|
|
|
|
[postgresql]
|
|
|
|
name=postgresql
|
|
|
|
stream=9.6
|
|
|
|
profiles=
|
|
|
|
state=enabled
|
|
|
|
when: inventory_hostname.startswith('db-fas01.stg')
|
|
|
|
|
|
|
|
- name: install postgresql server packages (EL < 8)
|
2019-06-11 17:10:06 +02:00
|
|
|
package:
|
|
|
|
state: present
|
|
|
|
name:
|
|
|
|
- postgresql-server
|
|
|
|
- postgresql-contrib
|
|
|
|
- postgresql-plpython
|
|
|
|
- python-psycopg2
|
|
|
|
- pxz
|
2019-09-19 19:27:25 +00:00
|
|
|
when: ansible_distribution_major_version|int < 8 and ansible_distribution == 'RedHat'
|
2016-08-10 12:39:24 +00:00
|
|
|
tags:
|
|
|
|
- packages
|
|
|
|
- postgresql
|
|
|
|
|
2022-06-07 15:40:56 -07:00
|
|
|
- name: install postgresql server packages (Fedora)
|
2019-06-11 17:10:06 +02:00
|
|
|
package:
|
|
|
|
state: present
|
|
|
|
name:
|
|
|
|
- postgresql-server
|
|
|
|
- postgresql-contrib
|
2022-06-07 15:40:56 -07:00
|
|
|
- postgresql-plpython3
|
|
|
|
- python3-psycopg2
|
2019-06-11 17:10:06 +02:00
|
|
|
- pxz
|
2019-09-19 19:27:25 +00:00
|
|
|
when: ansible_distribution_major_version|int >= 29 and ansible_distribution == 'Fedora' and ansible_cmdline.ostree is not defined
|
2019-09-02 12:14:18 +02:00
|
|
|
tags:
|
|
|
|
- packages
|
|
|
|
- postgresql
|
|
|
|
|
2022-06-07 15:40:56 -07:00
|
|
|
- name: install postgresql server packages (EL >= 8)
|
2019-09-02 12:14:18 +02:00
|
|
|
package:
|
|
|
|
state: present
|
|
|
|
name:
|
|
|
|
- postgresql-server
|
|
|
|
- postgresql-contrib
|
2020-04-21 15:45:39 +02:00
|
|
|
- postgresql-plpython3
|
|
|
|
- python3-psycopg2
|
2020-06-10 11:55:55 -07:00
|
|
|
- pxz
|
2019-09-19 19:27:25 +00:00
|
|
|
when: ansible_distribution_major_version|int >= 8 and ansible_distribution == 'RedHat' and ansible_cmdline.ostree is not defined
|
2013-06-24 21:27:04 +00:00
|
|
|
tags:
|
|
|
|
- packages
|
2014-09-25 20:26:49 +00:00
|
|
|
- postgresql
|
2013-06-24 21:27:04 +00:00
|
|
|
|
2014-09-25 20:42:43 +00:00
|
|
|
- name: Set kernel shared memory max to a larger value
|
2014-09-29 16:32:49 +02:00
|
|
|
sysctl: name=kernel.shmmax value={{ kernel_shmmax }}
|
|
|
|
when: kernel_shmmax is defined
|
2014-09-25 20:42:43 +00:00
|
|
|
notify:
|
|
|
|
- restart postgresql
|
2014-09-25 20:44:30 +00:00
|
|
|
tags:
|
|
|
|
- postgresql
|
2014-09-25 20:42:43 +00:00
|
|
|
|
2014-09-25 20:30:31 +00:00
|
|
|
- name: Initialize postgres if necessary
|
2014-09-30 14:26:55 +02:00
|
|
|
command: /usr/bin/postgresql-setup initdb
|
2018-03-03 01:46:46 +00:00
|
|
|
creates=/var/lib/pgsql/data/postgresql.conf
|
2014-09-25 20:30:31 +00:00
|
|
|
notify:
|
|
|
|
- restart postgresql
|
|
|
|
tags:
|
|
|
|
- postgresql
|
|
|
|
|
2013-06-26 20:14:32 +00:00
|
|
|
- name: Set postgresql-server to run on boot
|
|
|
|
service: name=postgresql enabled=yes
|
|
|
|
ignore_errors: true
|
|
|
|
notify:
|
|
|
|
- restart postgresql
|
|
|
|
tags:
|
|
|
|
- service
|
2014-09-25 20:26:49 +00:00
|
|
|
- postgresql
|
2014-01-10 20:40:08 +00:00
|
|
|
|
|
|
|
- name: Add our postgres config file.
|
|
|
|
copy: >
|
2014-01-10 20:52:18 +00:00
|
|
|
src={{ item }}
|
|
|
|
dest=/var/lib/pgsql/data/{{ item }}
|
2014-01-10 20:40:08 +00:00
|
|
|
owner=postgres
|
2014-01-10 20:52:18 +00:00
|
|
|
with_items:
|
|
|
|
- pg_hba.conf
|
2014-01-10 20:40:08 +00:00
|
|
|
notify:
|
|
|
|
- restart postgresql
|
|
|
|
tags:
|
|
|
|
- config
|
2014-09-25 20:26:49 +00:00
|
|
|
- postgresql
|
2014-01-10 21:29:20 +00:00
|
|
|
|
2020-06-22 15:08:23 -07:00
|
|
|
- name: postgresql config template (el7 / postgresql 9.2)
|
2014-12-08 14:47:06 +00:00
|
|
|
template: dest=/var/lib/pgsql/data/postgresql.conf src=postgresql.conf
|
2022-06-07 15:40:56 -07:00
|
|
|
when: ansible_distribution_major_version|int < 8 and ansible_distribution == 'RedHat'
|
2014-12-18 03:53:33 +00:00
|
|
|
notify:
|
|
|
|
- restart postgresql
|
2014-12-08 14:47:06 +00:00
|
|
|
tags:
|
2014-12-18 03:53:33 +00:00
|
|
|
- config
|
2014-12-08 14:47:06 +00:00
|
|
|
- postgresql
|
|
|
|
|
2022-06-07 15:40:56 -07:00
|
|
|
- name: postgresql config template (Fedora / el8 / postgresql 12)
|
2020-06-22 15:08:23 -07:00
|
|
|
template: dest=/var/lib/pgsql/data/postgresql.conf src=postgresql.conf-12
|
2022-06-07 15:40:56 -07:00
|
|
|
when: (ansible_distribution_major_version|int > 7 and ansible_distribution == 'RedHat') or ansible_distribution != 'RedHat'
|
2020-06-22 15:08:23 -07:00
|
|
|
notify:
|
|
|
|
- restart postgresql
|
|
|
|
tags:
|
|
|
|
- config
|
|
|
|
- postgresql
|
|
|
|
|
2014-01-10 21:29:20 +00:00
|
|
|
- name: Ensure postgres has a place to backup to
|
|
|
|
file: dest=/backups state=directory owner=postgres
|
2014-09-25 20:26:49 +00:00
|
|
|
tags:
|
|
|
|
- postgresql
|
2014-01-10 21:29:20 +00:00
|
|
|
|
2020-04-07 03:49:08 +00:00
|
|
|
- name: Copy over backup scriplet
|
|
|
|
copy: src=backup-database dest=/usr/local/bin/backup-database mode=0755
|
2020-06-18 18:54:12 -07:00
|
|
|
when: not inventory_hostname.startswith('db-koji01.iad2')
|
2020-04-07 03:49:08 +00:00
|
|
|
tags:
|
|
|
|
- postgresql
|
|
|
|
|
2014-01-13 16:16:18 +00:00
|
|
|
- name: Copy over backup scriplet
|
2020-06-14 19:51:22 -04:00
|
|
|
copy: src=backup-database.db-koji01 dest=/usr/local/bin/backup-database mode=0755
|
2020-06-09 14:29:28 -04:00
|
|
|
when: inventory_hostname.startswith('db-koji01.iad2')
|
2014-09-25 20:26:49 +00:00
|
|
|
tags:
|
|
|
|
- postgresql
|
2014-01-13 16:16:18 +00:00
|
|
|
|
2018-10-08 17:40:46 +00:00
|
|
|
- name: Copy over anitya public backup scriplet
|
|
|
|
copy: src=backup-database.anitya dest=/usr/local/bin/backup-database.anitya mode=0755
|
|
|
|
tags:
|
|
|
|
- postgresql
|
2020-06-09 14:29:28 -04:00
|
|
|
when: inventory_hostname.startswith('db01.phx2') or inventory_hostname.startswith('db01.iad2')
|
2018-10-08 17:40:46 +00:00
|
|
|
|
|
|
|
- name: Copy over anitya publib backup cron
|
2019-01-07 18:27:03 +00:00
|
|
|
copy: src=cron-backup-anitya-public dest=/etc/cron.d/cron-backup-anitya-public mode=0644
|
2018-10-08 17:40:46 +00:00
|
|
|
tags:
|
|
|
|
- postgresql
|
2020-06-09 14:29:28 -04:00
|
|
|
when: inventory_hostname.startswith('db01.phx2') or inventory_hostname.startswith('db01.iad2')
|
2018-10-08 17:40:46 +00:00
|
|
|
|
2014-01-10 21:29:20 +00:00
|
|
|
- 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
|
2014-09-25 20:26:49 +00:00
|
|
|
- postgresql
|
2014-10-01 20:29:25 +00:00
|
|
|
|
2016-04-13 17:46:12 +00:00
|
|
|
- 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
|
2016-04-13 18:22:49 +00:00
|
|
|
mode=0755
|
2016-04-13 17:46:12 +00:00
|
|
|
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
|
|
|
|
|
2015-04-27 16:24:27 +00:00
|
|
|
- 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
|
2015-04-27 18:25:55 +00:00
|
|
|
mode=755
|
2015-04-27 16:24:27 +00:00
|
|
|
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
|
2018-05-16 12:14:57 +02:00
|
|
|
|
|
|
|
- name: Set up datanommer/datagrepper SAR script
|
|
|
|
copy: >
|
|
|
|
src=datagrepper_sar.py
|
|
|
|
dest=/usr/local/bin/datagrepper_sar.py mode=0700
|
2020-06-21 09:20:12 -07:00
|
|
|
when: inventory_hostname.startswith('db-datanommer01')
|
2018-05-16 12:14:57 +02:00
|
|
|
tags:
|
|
|
|
- postgresql
|
|
|
|
- SAR
|
|
|
|
- GBDR
|
2021-08-10 10:37:06 +02:00
|
|
|
|
2021-08-10 10:53:06 +02:00
|
|
|
- import_tasks: datanommer.yml
|
2021-11-17 11:22:54 +01:00
|
|
|
when: inventory_hostname.startswith('db-datanommer02') or (env == "staging" and inventory_hostname.startswith('db-datanommer'))
|