mirror of
https://pagure.io/fedora-infra/ansible.git
synced 2026-04-28 20:42:20 +08:00
Currently backups are taking 17-18 hours with 4 threads. Now that we have 16 cpus defined there, lets bump that up to 8 and see if that lowers things much. If not we can look at moving to another compression, but the database is very large so lots of compression is good to save disk space. Also filter out another output of the backup job that causes cron emails. Signed-off-by: Kevin Fenzi <kevin@scrye.com>
192 lines
5.2 KiB
YAML
192 lines
5.2 KiB
YAML
---
|
|
#
|
|
# Setup postgresql server.
|
|
#
|
|
- 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
|
|
|
|
- name: on db-koji01 and db01.stg and db-fas01 and db01 enable the postgresql 15 module.
|
|
copy:
|
|
dest: /etc/dnf/modules.d/postgresql.module
|
|
content: |
|
|
[postgresql]
|
|
name=postgresql
|
|
stream=15
|
|
profiles=
|
|
state=enabled
|
|
when: inventory_hostname.startswith(('db-koji01','db01.stg','db-fas01','db01'))
|
|
|
|
- name: install postgresql server packages (EL < 8)
|
|
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 (Fedora)
|
|
package:
|
|
state: present
|
|
name:
|
|
- postgresql-server
|
|
- postgresql-contrib
|
|
- postgresql-plpython3
|
|
- python3-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 (EL >= 8)
|
|
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 (el7 / postgresql 9.2)
|
|
template: dest=/var/lib/pgsql/data/postgresql.conf src=postgresql.conf
|
|
when: ansible_distribution_major_version|int < 8 and ansible_distribution == 'RedHat'
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- config
|
|
- postgresql
|
|
|
|
- name: postgresql config template (Fedora / el8 / postgresql 12)
|
|
template: dest=/var/lib/pgsql/data/postgresql.conf src=postgresql.conf-12
|
|
when: (ansible_distribution_major_version|int == 8 and ansible_distribution == 'RedHat') or ansible_distribution != 'RedHat'
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- config
|
|
- postgresql
|
|
|
|
- name: postgresql config template (el9 / postgresql 15)
|
|
template: dest=/var/lib/pgsql/data/postgresql.conf src=postgresql.conf-15
|
|
when: (ansible_distribution_major_version|int == 9 and ansible_distribution == 'RedHat')
|
|
notify:
|
|
- restart postgresql
|
|
tags:
|
|
- config
|
|
- postgresql
|
|
|
|
- name: Ensure postgres has a place to backup to
|
|
file: dest=/backups state=directory owner=postgres
|
|
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-koji01.iad2','db-datanommer'))
|
|
tags:
|
|
- postgresql
|
|
|
|
- name: Copy over backup scriplet
|
|
copy: src=backup-database.db-koji01 dest=/usr/local/bin/backup-database mode=0755
|
|
when: inventory_hostname.startswith('db-koji01.iad2')
|
|
tags:
|
|
- postgresql
|
|
|
|
- name: Copy over backup scriplet
|
|
copy: src=backup-database.db-datanommer02 dest=/usr/local/bin/backup-database mode=0755
|
|
when: inventory_hostname.startswith('db-datanommer02.iad2')
|
|
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') or inventory_hostname.startswith('db01.iad2')
|
|
|
|
- name: Copy over anitya public 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.iad2')
|
|
|
|
- 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 datanommer/datagrepper SAR script
|
|
copy: >
|
|
src=datagrepper_sar.py
|
|
dest=/usr/local/bin/datagrepper_sar.py mode=0700
|
|
when: inventory_hostname.startswith('db-datanommer01')
|
|
tags:
|
|
- postgresql
|
|
- SAR
|
|
- GBDR
|
|
|
|
- import_tasks: datanommer.yml
|
|
when: inventory_hostname.startswith('db-datanommer02.iad2') or (env == "staging" and inventory_hostname.startswith('db-datanommer01.stg'))
|